My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

project of three dimensional calculator working with mouse

Tuesday, September 1, 2009

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

int aaa=247,bbb=167,l2,status,rep=0,mul=0;
char ch,st2[50],st1[2];
double f1=0,f2=0,d1=0,d2=0,d3=0;
void buttan1(int,int,int,int);
void buttan(int,int,int,int);
void text();
void screen(char);
void scremt();
void main()
{         int d,mm,e,a,b,c,k;
      d=DETECT;
      initgraph(&d,&mm,"c:/tc");
      e=graphresult();

      if(e!=0)
      {
          cout<<"Graphics not inialised";
          getch();
          return;
       }

       setbkcolor(BLUE);
       setcolor(7);
       rectangle(aaa-10,bbb-50,aaa+153,bbb+150);
       setfillstyle(1,7);
       floodfill(aaa,bbb,7);

       setcolor(15);
       int f[]={aaa-15,bbb-55,aaa+158,bbb-55,aaa+153,bbb-50,aaa-10,bbb-50,aaa-10,bbb+150,aaa-15,bbb+155,aaa-15,bbb-55};
       drawpoly(7,f);
       setfillstyle(1,15);
       floodfill(aaa-12,bbb-42,15);

       setcolor(8);
       int h[]={aaa+158,bbb-55,aaa+158,bbb+155,aaa-15,bbb+155,aaa-10,bbb+150,aaa+153,bbb+150,aaa+153,bbb-50,aaa+158,bbb-55};
       drawpoly(7,h);
       setfillstyle(1,8);
       floodfill(aaa+156,bbb-40,8);

       for(int ii=1;ii<17;ii++)
       {
          buttan(aaa,bbb,15,8);
          aaa+=39;
          if(ii%4==0)
          {  bbb+=39;
         aaa=247;
          }
       }
       buttan1(236,75,15,8);
       buttan1(350,75,15,8);
       aaa=247;
       bbb=167;
       text();
       scremt();


    REGS n,m;
    n.x.ax=0;
    int86(0x33,&n,&m);
    k=m.x.ax;
    if(k==0)
    return;
    int aa,bb,t1,t2;
    while(1)
    {  n.x.ax=1;
       int86(0x33,&n,&m);
       n.x.ax=3;
       int86(0x33,&n,&m);
       a=m.x.cx;
       b=m.x.dx;
       c=m.x.bx;
       // FOR EXIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       if(c==1 && a>350 && a<400 && b>75 && b<100)
       {    buttan1(350,75,8,15);
        delay(200);
        cleardevice();
        cleardevice();
        setcolor(RED);
        outtextxy(50,50,"MADE BY:");
        outtextxy(50,80,"UPINDER SINGH DHAMI");
        outtextxy(50,110,"B.TECH (FIFTH SEM)");
        outtextxy(50,140,"ELECTRONICS AND COMM ENGG");
        outtextxy(50,170,"GURU NANAK DEV UNIVERSITY (AMRITSAR)");
        outtextxy(50,200,"DATE: 17\\07\\2008");
        delay(7000);
        return;
       }
       // FOR RECET XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       if(c==1 && a>236 && a<286 && b>75 && b<100)
       {    rep=0;
        mul=0;
        buttan1(236,75,8,15);
        delay(200);
        buttan1(236,75,15,8);
        strcpy(st2,"");
        screen(' ');
        scremt();
       }

       // FOR  FIRST   ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       // FOR 7
       if(c==1 && a>aaa && a<(aaa+25) && b>bbb && b<(bbb+25))
       {
      buttan(aaa,bbb,8,15);
      delay(200);
      buttan(aaa,bbb,15,8);
      screen('7');
      mul=0;
      continue;
       }

       // FOR 8
       if(c==1 && a>(aaa+39) && a<(aaa+64) && b>bbb&&b<(bbb+25))
       {
       buttan((aaa+39),bbb,8,15);
       delay(200);
       buttan((aaa+39),bbb,15,8);
       screen('8');
       mul=0;
       continue;
       }

       // FOR 9
       if(c==1 && a>(aaa+78) && a<(aaa+103) && b>bbb&&b<(bbb+25))
       {
       buttan((aaa+78),bbb,8,15);
       delay(200);
       buttan((aaa+78),bbb,15,8);
       screen('9');
       mul=0;
       continue;
       }

       // FOR +
       if(c==1 && a>(aaa+117) && a<(aaa+142) && b>bbb&&b<(bbb+25))
       {   rep++;
       mul++;
       if(mul==2)
       { rep--;
         mul--;
       }
       if(rep==2)
       goto label;
       status=2;
       buttan((aaa+117),bbb,8,15);
       delay(200);
       buttan((aaa+117),bbb,15,8);
       d1=f1;
       strcpy(st2,"");
       scremt();
       continue;
       }

       //FOR SECOND ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       // FOR 4
       if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+39) && b<(bbb+64))
       {
      buttan(aaa,bbb+39,8,15);
      delay(200);
      buttan(aaa,bbb+39,15,8);
      screen('4');
      mul=0;
      continue;
       }

       //FOR 5
       if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+39) && b<(bbb+64))
       {
      buttan(aaa+39,bbb+39,8,15);
      delay(200);
      buttan(aaa+39,bbb+39,15,8);
      screen('5');
      mul=0;
      continue;
       }

       //FOR 6
       if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+39) && b<(bbb+64))
       {
      buttan(aaa+78,bbb+39,8,15);
      delay(200);
      buttan(aaa+78,bbb+39,15,8);
      screen('6');
      mul=0;
      continue;
       }

       //FOR -
       if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+39) && b<(bbb+64))
       {   rep++;
       mul++;
       if(mul==2)
       { rep--;
         mul--;
       }
       if(rep==2)
       goto label;
      status=3;
      buttan(aaa+117,bbb+39,8,15);
      delay(200);
      buttan(aaa+117,bbb+39,15,8);
      d1=f1;
      strcpy(st2,"");
      scremt();
      continue;
       }

       // FOR THIRD ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       // FOR 1
       if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+78) && b<(bbb+103))
       {
      buttan(aaa,bbb+78,8,15);
      delay(200);
      buttan(aaa,bbb+78,15,8);
      screen('1');
      mul=0;
      continue;
       }

       //FOR 2
       if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+78) && b<(bbb+103))
       {
      buttan(aaa+39,bbb+78,8,15);
      delay(200);
      buttan(aaa+39,bbb+78,15,8);
      screen('2');
      mul=0;
      continue;
       }

       //FOR 3
       if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+78) && b<(bbb+103))
       {
      buttan(aaa+78,bbb+78,8,15);
      delay(200);
      buttan(aaa+78,bbb+78,15,8);
      screen('3');
      mul=0;
      continue;
       }

       //FOR *
       if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+78) && b<(bbb+103))
       {   rep++;
       mul++;
       if(mul==2)
       { rep--;
         mul--;
       }
       if(rep==2)
       goto label;
      status=1;
      buttan(aaa+117,bbb+78,8,15);
      delay(200);
      buttan(aaa+117,bbb+78,15,8);
      d1=f1;
      strcpy(st2,"");
      scremt();
      continue;
       }

       // FOR FORTH ROW XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
       // FOR 0
       if(c==1 && a>aaa && a<(aaa+25) && b>(bbb+117) && b<(bbb+142))
       {
      buttan(aaa,bbb+117,8,15);
      delay(200);
      buttan(aaa,bbb+117,15,8);
      screen('0');
      mul=0;
      continue;
       }

       // FOR .
       if(c==1 && a>(aaa+39) && a<(aaa+64) && b>(bbb+117) && b<(bbb+142))
       {
      buttan(aaa+39,bbb+117,8,15);
      delay(200);
      buttan(aaa+39,bbb+117,15,8);
      screen('.');
      mul=0;
      continue;
       }

       // FOR =
       if(c==1 && a>(aaa+78) && a<(aaa+103) && b>(bbb+117) && b<(bbb+142))
       {
      buttan(aaa+78,bbb+117,8,15);
      delay(200);
      buttan(aaa+78,bbb+117,15,8);
      label:
      if(status==1)
      {  d2=f1;
         d3=d1*d2;
      }
      if(status==2)
      {  d2=f1;
         d3=d1+d2;
      }
      if(status==3)
      {  d2=f1;
         d3=d1-d2;
      }
      if(status==4)
      {  d2=f1;
         d3=d1/d2;
      }
      char temp[50];
      int sig = 10;

      gcvt(d3, sig, temp);
      strcpy(st2,"");
      strcpy(st2,temp);
      scremt();
      screen(' ');
      rep=0;
      mul=0;
      continue;
       }

       // FOR %
       if(c==1 && a>(aaa+117) && a<(aaa+142) && b>(bbb+117) && b<(bbb+142))
       {   rep++;
       mul++;
       if(mul==2)
       { rep--;
         mul--;
       }
       if(rep==2)
       goto label;
      status=4;
      buttan(aaa+117,bbb+117,8,15);
      delay(200);
      buttan(aaa+117,bbb+117,15,8);
      d1=f1;
      strcpy(st2,"");
      scremt();
      continue;
       }

    }
 getch();
closegraph();
}

       void buttan(int x, int y,int ltcolor,int rtcolor)
       {

           setcolor(7);
           rectangle(x,y,x+25,y+25);
           setfillstyle(1,7);
           floodfill(x+2,y+2,7);

           setcolor(ltcolor);
           int a[]={ x-2,y-2,x+27,y-2,x+25,y,x,y,x,y+25,x-2,y+27,x-2,y-2};
           drawpoly(7,a);
           setfillstyle(1,ltcolor);
           floodfill(x-1,y+5,ltcolor);

           setcolor(rtcolor);
           int b[]={x+27,y-2,x+27,y+27,x-2,y+27,x,y+25,x+25,y+25,x+25,y,x+27,y-2 };
           drawpoly(7,b);
           setfillstyle(1,rtcolor);
           floodfill(x+26,y+5,rtcolor);
        }
        void text()
        {  setcolor(4);
           outtextxy(aaa+9,bbb+10,"7");
           outtextxy(aaa+48,bbb+10,"8");
           outtextxy(aaa+87,bbb+10,"9");
           outtextxy(aaa+126,bbb+10,"+");
           outtextxy(aaa+9,bbb+49,"4");
           outtextxy(aaa+48,bbb+49,"5");
           outtextxy(aaa+87,bbb+49,"6");
           outtextxy(aaa+126,bbb+49,"-");
           outtextxy(aaa+9,bbb+88,"1");
           outtextxy(aaa+48,bbb+88,"2");
           outtextxy(aaa+87,bbb+88,"3");
           outtextxy(aaa+126,bbb+88,"*");
           outtextxy(aaa+9,bbb+127,"0");
           outtextxy(aaa+48,bbb+124,".");
           outtextxy(aaa+87,bbb+127,"=");
           outtextxy(aaa+126,bbb+127,"%");
           outtextxy(243,85,"RESET");
           outtextxy(361,85,"EXIT");
           settextstyle(7,HORIZ_DIR,1);
           outtextxy(aaa+50,bbb+250,"MADE BY: UPINDER SINGH DHAMI");

           settextstyle(0,0,1);
        }
        void screen(char ch)
        {  setcolor(15);
           rectangle(aaa-5,bbb-40,aaa+148,bbb-10);
           setfillstyle(1,15);
           floodfill(aaa,bbb-20,15);
       //    outtextxy(aaa+140,bbb,"0.");
           scremt();
           if(ch!='a')
           {
           setcolor(1);
           st1[0]=ch;
           st1[1]='\0';
           strcat(st2,st1);
           }
           l2=strlen(st2);
           if(l2>19)
           {        scremt();
            setcolor(BLUE);
            outtextxy(250,136," data overflow");
            return;
           }
           f1 = atof(st2);
           outtextxy(395-(l2*8),136,st2);

        }
        void scremt()
        {  setcolor(14);
           rectangle(aaa-5,bbb-40,aaa+148,bbb-10);
           setfillstyle(1,14);
           floodfill(aaa,bbb-20,14);
        }

        void buttan1(int x, int y,int ltcolor,int rtcolor)
        {

           setcolor(7);
           rectangle(x,y,x+50,y+25);
           setfillstyle(1,7);
           floodfill(x+2,y+2,7);

           setcolor(ltcolor);
           int a[]={ x-4,y-4,x+54,y-4,x+50,y,x,y,x,y+25,x-4,y+29,x-4,y-4};
           drawpoly(7,a);
           setfillstyle(1,ltcolor);
           floodfill(x-3,y-3,ltcolor);

           setcolor(rtcolor);
           int b[]={x+54,y-4,x+54,y+29,x-4,y+29,x,y+25,x+50,y+25,x+50,y,x+54,y-4};
           drawpoly(7,b);
           setfillstyle(1,rtcolor);
           floodfill(x+52,y+10,rtcolor);

           setcolor(1);

        }

0 comments: