Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Monday, 31 March 2014

C Programming graphics | Web browser project in c, c program to open a website/url using C graphics

C Programming graphics | Web browser project in c, c program to open a website/url using C graphics

Source code:-)

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <graphics.h>
#include <dos.h>
#include <string.h>

void initialize_graphics_mode();
int get_key();
void draw();

union REGS i, o;

main()
{
  int key, i = 0, xpos, ypos, button;
  char arr[200], temp[5], *ptr;
  char a[] = "C:\\Progra~1\\Mozill~1\\firefox ";

  strcpy(arr,a);

  i = strlen(a);

  initialize_graphics_mode();

  draw();

  while(1)
  {
    if(kbhit())
      key = get_key();

    if((key>=97&&key<=122)||(key>=65&&key<=90)||key==46||key==47||key==63)
    {
      arr[i] = key;
      sprintf(temp,"%c",arr[i]);
      outtext(temp);
      if(getx()>470)
      {
        clearviewport();
        moveto(5,2);
      }
      i++;
    }
    else if ( key == 13 )
    {
      arr[i] = '\0';
      system(arr);
      break;
    }
    else if ( key == 27 )
    {
      closegraph();
      exit(EXIT_SUCCESS);
    }
    if(button==1&&xpos>=150&&xpos<=480&&ypos>=300&&ypos<=330)
    {
      system("C:\\Progra~1\\Mozill~1\\firefox errors000.blogspot.in");
      break;
    }
    key = -1;
  }

  closegraph();
  return 0;
}

void initialize_graphics_mode()
{
  int gd = DETECT, gm, errorcode;

  initgraph(&gd,&gm,"C:\\TC\\BGI");
  errorcode = graphresult();

  if( errorcode != grOk )
  {
    printf("Graphics error : %s\n",grapherrormsg(errorcode));

    printf("Press any key to exit...\n");
    getch();
    exit(EXIT_FAILURE);
  }
}

int get_key()
{
  i.h.ah = 0;
  int86(22,&i,&o);

  return( o.h.al );
}

void draw()
{
  settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
  outtextxy(275,11,"Web Browser");
  outtextxy(155,451,"<a href="http://errors000.blogspot.in"">errors000.blogspot.in"</a>);
  outtextxy(5,105,"Enter URL : ");
  rectangle(120,100,600,130);
  setviewport(121,101,599,129,1);
  moveto(5,1);
}

Sunday, 30 March 2014

JAVA PROGRAMS-Matrix Program in Java

Matrix Program in Java

  Program Name:- matrix.java 

import java.io.*;

class matrix

{

public static void main(String args[])throws IOException

{

 DataInputStream in=new DataInputStream(System.in);

 int i,j,m,n,k;

 int a[][]=new int[10][10];

 int b[][]=new int[10][10];

 int c[][]=new int[10][10];

 int d[][]=new int[10][10];

 System.out.print("\n Enter the row and column\n\n");

 m=Integer.parseInt(in.readLine());

 n=Integer.parseInt(in.readLine());

 System.out.print("\n Enter the element of matrix A\n\n");

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 a[i][j]=Integer.parseInt(in.readLine());

 }

 }

 System.out.print("\n Enter the element of matrix B\n\n");

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 b[i][j]=Integer.parseInt(in.readLine());

 }

 }

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 for(k=0;k<m;k++)

 {

 c[i][j]=c[i][j]+a[i][k]*b[k][j];

 }

 }

 }

 System.out.print("\n A matrix\n");

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 System.out.print(a[i][j]+"\t");

 }

 System.out.println();

 }

 System.out.print("\n B matrix\n");

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 System.out.print(b[i][j]+"\t");

 }

 System.out.println();

 }

 System.out.print("\n Multipul matrix\n");

 for(i=0;i<m;i++)

 {

 for(j=0;j<n;j++)

 {

 System.out.print(c[i][j]+"\t");

 }

 System.out.println();

 }

 }

}


JAVA PROGRAMS-Interface Demo program in java

Interface Demo program in java

Program Name:- inter1

import java.io.*;

interface demo

{

final double pi=3.14;

abstract double area(int r);

}

interface demo1

{

abstract double circum(int r);

}

class cir implements demo,demo1

{

public double area(int r)

{

return pi*r*r;

}

public double circum(int a)

{

return 2*pi*a*a;

}

}

class inter1

{

public static void main(String arg[])

{

cir c=new cir();

System.out.print("\nCircle\t:"+c.area(5));

System.out.print("\nCircum\t:"+c.circum(5));

}

}


JAVA PROGRAMS-Multi Level Inheritance in Java

Multi Level Inheritance in Java

Program Name:- multi.java

import java.io.*;

class box1

{

int length,width,height;

box1()

 {

 length=0;

 width=0;

 height=0;

 }

box1(int l)

 {

 length=width=height=l;

 }

box1(int l,int w,int h)

 {

 length=l;

 width=w;

 height=h;

 }

int volume()

 {

 int v;

 v=length*width*height;

 return(v);

 }

}

class boxweight extends box1

{

double weight;

boxweight()

 {

 super();

 weight=0;

 }

boxweight(int l,double m)

 {

 super(l);

 weight=m;

 }

boxweight(int l,int w,int h,double m)

 {

 super(l,w,h);

 weight=m;

 }

}

class shipping extends boxweight

{

double cost;

shipping()

 {

 super();

 cost=0;

 }

shipping(int l,double m,double c)

 {

 super(l,m);

 cost=c;

 }

shipping(int l,int h,int w,double m,double c)

 {

 super(l,w,h,m);

 cost=c;

 }

}

class multi

{

public static void main(String args[])

{

shipping s1=new shipping(10,5,7,100.1,150.2);

shipping s2=new shipping(5,2,10,20.0,115.50);

double vol1,vol2;

vol1=s1.volume();

vol2=s2.volume();

System.out.println("\n\t Shipping list");

System.out.print("\n\n Volume weight cost");

System.out.print("\n"+vol1+" "+s1.weight+"rs\t"+s1.cost);

System.out.print("\n"+vol2+" "+s2.weight+"rs\t"+s2.cost);

 }

}