C Program To Create A Perfect Calculator



#include<constream.h>
#include<stdlib.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include<math.h>
union REGS i,o;                     //FOR HARDWARE INTERFACE

class Window
{ protected:
  public:
 void win()
 { setbkcolor(BLACK);         setcolor(LIGHTGRAY);
   setfillstyle(SOLID_FILL,LIGHTGRAY);
   rectangle(1,1,631,478);    floodfill(2,2,LIGHTGRAY);
   setcolor(BLUE);            setfillstyle(SOLID_FILL,BLUE);
   //TASK BAR
   rectangle(5,5,625,26);     floodfill(6,6,BLUE);
   setcolor(WHITE);           settextstyle(7,0,1);
   outtextxy(12,3,"02_Batch Software");
   //MAX: BUTTON
   setcolor(LIGHTGRAY);       rectangle(592,9,604,22);
   setfillstyle(SOLID_FILL,LIGHTGRAY);
   floodfill(594,10,LIGHTGRAY);   setcolor(BLACK);
   line(604,9,604,22);            line(592,22,604,22);
   rectangle(594,11,599,18);      rectangle(596,13,601,20);
   setcolor(WHITE);               line(592,9,604,9);
   line(592,9,592,22);
  //MIN: BUTTON
   setcolor(LIGHTGRAY);           rectangle(575,9,587,22);
   setfillstyle(SOLID_FILL,LIGHTGRAY);
   floodfill(576,10,LIGHTGRAY);   setcolor(BLACK);
   line(587,9,587,22);            line(575,22,587,22);
   line(578,16,584,16);           setcolor(WHITE);
   line(575,9,587,9);             line(575,9,575,22);
   //CLOSE BUTTON
   setcolor(LIGHTGRAY);           rectangle(609,9,621,22);
   setfillstyle(SOLID_FILL,LIGHTGRAY);
   floodfill(610,10,LIGHTGRAY);   setcolor(BLACK);
   line(621,9,621,22);            line(609,22,621,22);
   setlinestyle(SOLID_LINE,0,3);   line(612,12,618,18);
   line(618,12,612,18);           setlinestyle(SOLID_LINE,0,1);
   setcolor(WHITE);               line(609,9,620,9);
   line(609,9,609,21);            setcolor(DARKGRAY);
   //RECTANGLE FOR MENUS AND SELECTIONS
   rectangle(5,28,625,120);
  //LINES FOR MENU BAR
   line(9,55,575,55);            line(575,55,575,30);
   //LINES FOR ADRESS BAR
   line(8,95,622,95);
   line(64,98,64,118);//vertical
   line(613,98,613,115);//right vertical
   line(613,115,601,115);//down horizontal
   //  LINE FOR DRAGER 1
   line(16,60,16,90);           line(16,90,14,90);
   // LINE FOR DRAGER 2
   line(16,33,16,48);           line(16,48,14,48);
   //  LINE FOR DRAGER 1
   line(16,100,16,115);         line(16,115,14,115);
   setcolor(WHITE);
  //LINES WITH ABOVE RECTANLE
   line(6,29,624,29);           line(6,29,6,119);
   //LINES WITH MENU BAR
   line(9,56,624,56);           line(576,55,576,30);
   //LINES FOR DRAGER 1
  line(14,33,14,48);            line(14,33,16,33);
  //LINES FOR DRAGER 2
  line(14,60,14,90);            line(14,60,16,60);
   //LINES FOR DRAGER 3
  line(14,100,14,115);          line(14,100,16,100);
  //LINES FOR ADRESS BAR
  line(64,118,616,118);         line(616,118,616,96);
  line(613,99,600,99);          line(600,99,600,115);
  line(8,96,622,96);
 //RECTANGLE FOR ADRESS BAR
  setfillstyle(SOLID_FILL,WHITE);
  rectangle(66,99,599,116);     floodfill(67,100,WHITE);
   setcolor(BLACK);
  //LINES FOR ADRESS BAR
   line(65,97,614,97);//up horizonal
   line(614,97,614,116);//right vertical
   line(65,97,65,116);//left vertical
   line(614,116,600,116);//down horizontal
   line(605,107,609,107);//adress bar button trianle
   line(606,108,608,108);       line(607,109,607,109);
   setfillstyle(SOLID_FILL,BLACK);
   rectangle(577,30,623,55);    floodfill(578,31,BLACK);
   //MENUS
   setcolor(BLACK);             settextstyle(2,0,4);
   outtextxy(35,38,"File");     line(34,50,37,50);
   outtextxy(70,38,"Edit");     line(69,50,72,50);
   outtextxy(110,38,"View");    line(110,50,113,50);
   outtextxy(145,38,"Go");      line(145,50,148,50);
   outtextxy(180,38,"Favourites");
   line(186,50,190,50);         outtextxy(255,38,"Help");
   line(255,50,258,50);         outtextxy(19,102,"Address");
   line(34,114,37,114);
   outtextxy(79,102,"Object Oriented Programing in C++");
   /////**************************TOOLS BAR***************/////
   //BACK
   setcolor(DARKGRAY);
   setfillstyle(SOLID_FILL,DARKGRAY);    line(55,70,75,70);
   line(75,70,75,80);                    line(75,80,55,80);
   line(55,80,55,85);                    line(55,85,45,75);
   line(45,75,55,65);                    line(55,65,55,70);
   floodfill(56,76,DARKGRAY);
}
void anticlose()
{   setcolor(LIGHTGRAY);   rectangle(609,9,621,22);
    setfillstyle(SOLID_FILL,LIGHTGRAY);
    floodfill(610,10,LIGHTGRAY);   setcolor(WHITE);
   line(621,9,621,22);             line(609,22,621,22);
   setlinestyle(SOLID_LINE,0,1);   setcolor(BLACK);
   setlinestyle(SOLID_LINE,0,3);   line(612,12,618,18);
   line(618,12,612,18);            line(609,9,620,9);
   line(609,9,609,21);
}
void info()
{ setcolor(DARKGRAY);             line(25,185,190,185);
  line(25,185,25,410);            setcolor(WHITE);
  line(190,185,190,410);          line(25,410,190,410);
  setcolor(DARKGRAY);                settextstyle(4,0,1);
  outtextxy(30,190,"Group members:");
  line(30,213,150,213);           line(30,214,150,214);
  delay(200);     outtextxy(30,220,"Naeem");
  delay(200);     outtextxy(45,245,"Ahmed");
  delay(200);     outtextxy(55,270,"Mahoto");
  delay(200);     outtextxy(30,295,"Roll No: 02SW08");
  delay(200);     outtextxy(30,345,"First Year");
  delay(200);     outtextxy(97,370,"2nd Term");
}
  void anti_info()
{  setcolor(LIGHTGRAY);            line(25,185,190,185);
  line(25,185,25,410);             line(190,185,190,410);
  line(25,410,190,410);            settextstyle(4,0,1);
  outtextxy(30,190,"Group members:");
  line(30,213,150,213);            line(30,214,150,214);
  outtextxy(30,220,"Naeem");
  outtextxy(45,245,"Ahmed");
  outtextxy(55,270,"Mahoto");  outtextxy(30,295,"Roll No: 02SW08");
  outtextxy(30,345,"First Year");  outtextxy(97,370,"2nd Term");
}
};                               //END OF WINDOW CLASS
class Mouse
{  protected:
   public:
void initmouse()
{ i.x.ax=0;
  int86(0x33,&i,&o);
}
void showmouse()
{  i.x.ax=1;
   int86(0x33,&i,&o);
}
void position(int *button,int*x,int*y)
{ i.x.ax=3;
  int86(0x33,&i,&o);
  *button=o.x.bx;
  *x=o.x.cx;
  *y=o.x.dx;
}
};                     //END OF MOUSE CLASS
  class Calculator
{  protected:
   public:
void calculator()
{    //MAIN RECTANGLE
   setcolor(WHITE);             rectangle(209,134,411,428);
   rectangle(210,135,410,427);  setcolor(DARKGRAY);
   rectangle(208,133,412,429);  rectangle(213,137,408,425);    //INNER MOST
   setfillstyle(SOLID_FILL,DARKGRAY);
   floodfill(214,138,DARKGRAY);  setcolor(WHITE);
   settextstyle(2,0,4);          outtextxy(220,142,"Calculator");
   //SCREEN
   setcolor(WHITE);              rectangle(225,167,397,193);
   setfillstyle(SOLID_FILL,WHITE);
   floodfill(226,170,WHITE);     rectangle(223,165,399,195);
   setcolor(DARKGRAY);           rectangle(221,163,401,197);
   //CE BUTTON
   setcolor(LIGHTGRAY);          rectangle(363,205,393,235);
   setfillstyle(SOLID_FILL,LIGHTGRAY);
   floodfill(364,206,LIGHTGRAY);  setcolor(RED);
   settextstyle(2,0,5);           outtextxy(372,213,"CE");
   setcolor(WHITE);               line(363,205,393,205);
   line(363,205,363,235);
   //BUTTONS
   int x=229,y=245;
   for(int j=x;j<=400;j+=45)
   {   for(int k=y;k<=385;k+=45)
     {  setcolor(LIGHTGRAY);
 rectangle(j,k,j+30,k+30);
 setfillstyle(SOLID_FILL,LIGHTGRAY);
 floodfill(j+1,k+1,LIGHTGRAY);
 setcolor(WHITE); line(j,k,j+30,k);
 line(j,k,j,k+30);
     }
   }
  //TEXT ON BUTTONS
  setcolor(BLUE);               settextstyle(2,0,5);
  outtextxy(x+12,y+7,"7");      outtextxy(x+57,y+7,"8");
  outtextxy(x+102,y+7,"9");     outtextxy(x+147,y+7,"/");

  outtextxy(x+12,y+52,"4");     outtextxy(x+57,y+52,"5");
  outtextxy(x+102,y+52,"6");    outtextxy(x+147,y+52,"*");

  outtextxy(x+12,y+97,"1");     outtextxy(x+57,y+97,"2");
  outtextxy(x+102,y+97,"3");    outtextxy(x+147,y+97,"-");

  outtextxy(x+12,y+142,"0");    outtextxy(x+59,y+140,".");
  outtextxy(x+102,y+142,"=");   outtextxy(x+147,y+142,"+");
}                    //      END OF CALCULATOR FUNCTION
void credit()
{
   setcolor(LIGHTGRAY);        line(34,163,50,163);
   line(34,162,42,154);        line(42,154,50,162);
  setcolor(WHITE);
   line(25,145,190,145);         line(25,145,25,170);
   setcolor(DARKGRAY);           line(25,170,190,170);
   line(190,145,190,170);        line(32,156,40,164);
   line(40,164,48,156);          setcolor(WHITE);
   line(32,155,48,155);          setcolor(BLUE);
   settextstyle(7,0,1);          outtextxy(85,147,"Credit");
}
void anticredit()
{  setcolor(LIGHTGRAY);
   line(32,156,40,164);        line(40,164,48,156);
   line(32,155,48,155);        setcolor(DARKGRAY);
   line(25,145,190,145);       line(25,145,25,170);
   setcolor(WHITE);
   line(25,170,190,170);       line(190,145,190,170);
   //UP ARROW
   line(34,163,50,163);        setcolor(DARKGRAY);
   line(34,162,42,154);        line(42,154,50,162);
   setcolor(BLUE);             settextstyle(7,0,1);
   outtextxy(85,147,"Credit");
}
void anti7()
{  setcolor(DARKGRAY);        line(229,245,259,245);
   line(229,245,229,275);     setcolor(WHITE);
   line(229,275,259,275);     line(259,245,259,275);
}
void anti8()
{  setcolor(DARKGRAY);        line(274,245,304,245);
   line(274,245,274,275);     setcolor(WHITE);
   line(274,275,304,275);     line(304,245,304,275);
}
void anti9()
{ setcolor(DARKGRAY);        line(319,245,349,245);
   line(319,245,319,275);    setcolor(WHITE);
   line(319,275,349,275);    line(349,245,349,275);
}
void antidivide()
{ setcolor(DARKGRAY);       line(364,245,394,245);
   line(364,245,364,275);   setcolor(WHITE);
   line(364,275,394,275);   line(394,245,394,275);
}
void anti4()
{ setcolor(DARKGRAY);       line(229,290,259,290);
   line(229,290,229,320);   setcolor(WHITE);
   line(229,320,259,320);   line(259,290,259,320);
}
void anti5()
{ setcolor(DARKGRAY);       line(274,290,304,290);
   line(274,290,274,320);   setcolor(WHITE);
   line(274,320,304,320);   line(304,290,304,320);
}
void anti6()
{ setcolor(DARKGRAY);       line(319,290,349,290);
   line(319,290,319,320);   setcolor(WHITE);
   line(319,320,349,320);   line(349,290,349,320);
}
void antimult()
{ setcolor(DARKGRAY);       line(364,290,394,290);
   line(364,290,364,320);   setcolor(WHITE);
   line(364,320,394,320);   line(394,290,394,320);
}
void anti1()
{ setcolor(DARKGRAY);      line(229,335,259,335);
  line(229,335,229,365);   setcolor(WHITE);
  line(229,365,259,365);   line(259,335,259,365);
}
void anti2()
{ setcolor(DARKGRAY);     line(274,335,304,335);
  line(274,335,274,365);  setcolor(WHITE);
  line(274,365,304,365);  line(304,335,304,365);
}
void anti3()
{ setcolor(DARKGRAY);     line(319,335,349,335);
  line(319,335,319,365);  setcolor(WHITE);
  line(319,365,349,365);  line(349,335,349,365);
}
void antiminus()
{ setcolor(DARKGRAY);     line(364,335,394,335);
  line(364,335,364,365);  setcolor(WHITE);
  line(364,365,394,365);  line(394,335,394,365);
}
void anti0()
{ setcolor(DARKGRAY);     line(229,380,259,380);
  line(229,380,229,410);  setcolor(WHITE);
  line(229,410,259,410);  line(259,380,259,410);
}
void antidot()
{ setcolor(DARKGRAY);     line(274,380,304,380);
  line(274,380,274,410);  setcolor(WHITE);
  line(274,410,304,410);  line(304,380,304,410);
}
void antiequal()
{ setcolor(DARKGRAY);     line(319,380,349,380);
  line(319,380,319,410);  setcolor(WHITE);
  line(319,410,349,410);  line(349,380,349,410);
}
void antiplus()
{ setcolor(DARKGRAY);     line(364,380,394,380);
  line(364,380,364,410);  setcolor(WHITE);
  line(364,410,394,410);  line(394,380,394,410);
}
void antiCE()
{ setcolor(DARKGRAY);      line(363,205,393,205);
  line(363,205,363,235);   setcolor(WHITE);
  line(393,205,393,235);   line(363,235,393,235);
}
};                          // END OF CALCULATOR CLASS
class Submain
{ protected:
  public:
void submain()
{  Window w;        Mouse n;        Calculator c;
   Calculation cc;  w.win();         c.calculator();
int i,o,button;     int xx=235,yy=170;  //START OF DIGITS ON SCREEN
int dgt=0;                              //ARRAY VAR'S VARIABLE
char var[11];
int check1=1;                           //CHECKS DOT COUNTING
for ( ; ; )
{                                      //START OF FOR LOOP
n.position(&button,&i,&o);             // MOUSE INITIALIZATION
if ( (button &1)&&(i>=229 && i<=259) && (o>=380 && o<=410) )//ZERO
 {  c.anti0();
if(xx<=347)            //LIMIT OF DIGITS ON SCREEN
    { setcolor(BLACK);           settextstyle(2,0,7);
      outtextxy(xx,yy,"0");       var[dgt]='0';
      xx+=12;                     dgt++;
     }     delay(200);            c.calculator();
 }
if ( (button &1)&&(i>=274 && i<=304) && (o>=380 && o<=410) )//DOT
 { c.antidot();
 if(xx<=330 && check1%2!=0)   //ONCE ONLY DOT WILL BE PRINTED
  { setcolor(BLACK);             settextstyle(2,0,7);
  outtextxy(xx,yy,".");          var[dgt]='.';
  dgt++;       xx+=8;            check1++;
  }    delay(200);               c.calculator();
 }
 if ( (button &1)&&(i>=319 && i<=349) && (o>=380 && o<=410) )//EQUAL
 { c.antiequal();      delay(200);     c.calculator();
   setcolor(BLACK);    settextstyle(2,0,7);
   xx=235;yy=170;      outtextxy(235,170,var);
 }
 if ( (button &1)&&(i>=364 && i<=394) && (o>=380 && o<=410) )//PLUS
 { c.antiplus();       delay(200);        c.calculator();
   char *add=var;      cc.addition(add);
 }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=335 && o<=365) )//ONE
  {  c.anti1();
  if(xx<=347)
   {  setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"1");
      var[dgt]='1';      dgt++;    xx+=12;
   }  delay(200);        c.calculator();
  }

 if ( (button &1)&&(i>=274 && i<=304) && (o>=335 && o<=365) )//TWO
  {  c.anti2();
   if(xx<=347)
    { setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"2");
      var[dgt]='2';      dgt++;                xx+=12;
    } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=335 && o<=365) )//THREE
 {  c.anti3();
   if(xx<=347)
   { setcolor(BLACK);    settextstyle(2,0,7);   outtextxy(xx,yy,"3");
     var[dgt]='3';       dgt++;                 xx+=12;
   } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=335 && o<=365) )//MINUS
 { c.antiminus();        delay(200);          c.calculator();
   char *sbt=var;        cc.subtract(sbt);
 }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=290 && o<=320) )//FOUR
 { c.anti4();
  if(xx<=347)
  { setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"4");
    var[dgt]='4';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=290 && o<=320) )//FIVE
 {  c.anti5();
  if(xx<=347)
  { setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"5");
    var[dgt]='5';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=290 && o<=320) )//SIX
 {  c.anti6();
  if(xx<=347)
  { setcolor(BLACK);    settextstyle(2,0,7);  outtextxy(xx,yy,"6");
    var[dgt]='6';       dgt++;                xx+=12;
  } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=290 && o<=320) )//MULT
 {  c.antimult();      delay(200);            c.calculator();
    char *mlt=var;     cc.multiply(mlt);
 }
if ( (button &1)&&(i>=229 && i<=259) && (o>=245 && o<=275) )//SEVEN
 {  c.anti7();
  if(xx<=347)
  { setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"7");
    var[dgt]='7';      dgt++;                 xx+=12;
  } delay(200);        c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=245 && o<=275) )//EIGHT
  { c.anti8();
  if(xx<=347)
   { setcolor(BLACK);  settextstyle(2,0,7);   outtextxy(xx,yy,"8");
     var[dgt]='8';     dgt++;                 xx+=12;
   } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=245 && o<=275) )//NINE
  { c.anti9();
  if(xx <=347)
   { setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"9");
     var[dgt]='9';      dgt++;                xx+=12;
   } delay(200);        c.calculator();
  }
  if ( (button &1)&&(i>=364 && i<=394) && (o>=245 && o<=275) )//DIVISION
 {  c.antidivide();     delay(200);           c.calculator();
    char *div=var;       cc.divide(div);
 }
 if ( (button &1)&&(i>=609 && i<=621) && (o>=9 && o<=22) )//CLOSE
 {  w.anticlose();     delay(200);        exit(1); }

 if ( (button &1)&&(i>=363 && i<=393) && (o>=205 && o<=335) )//CE
 {  c.antiCE();           delay(200);        c.calculator();
  setcolor(WHITE);                    // CLEARS SCREEN
  settextstyle(2,0,7);    outtextxy(235,170,var);
  var[dgt]=0;   dgt=0;   check1--;   //AGAIN SET CONDITION TO PRINT DOT
  xx=235;yy=170;
  }
 if ( (button &2)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//ANTI_CREDIT
       { c.anticredit();  w.info();   }
 if ( (button &1)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//CREDIT
       {  c.credit();     w.anti_info(); }

} ////////////////////////END OF FOR//////////////////////////////////
}        //////////////////END OF SUBMAIN FUNCTION////////////////*/
};                           //END OF SUBMAIN CLASS
class Base
{  protected:
   public:
void addition(char*);               //PROTOTYPES
void subtract(char*);
void multiply(char*);
void divide(char*);
};            ///////////END OF BASE CLASS///////////

class Calculation:public Base    //INHERITED CLASS
{  public:

};                           //END OF CALCULATION CLASS

       //////////START OF MAIN PROGRAM/////////////
int main()
{  clrscr();
   int d=0,m;  int button,i,o;
   initgraph(&d,&m,"..\\bgi");
   Window w;        Mouse n;        Calculator c;
   Calculation cc;
   w.win();         c.calculator(); c.credit();
   n.initmouse();   n.showmouse();      Submain s;
  for ( ; ; )                    //INFINITE TIMES
   {    n.position(&button,&i,&o);
 s.submain();
   }                             //END OF FOR
     closegraph();
     return 0;
}                                //END OF MAIN

       ///////////DECLARATOR OF ADDITION//////////////
void Base::addition(char*newvar)
{

   double total=atof(newvar);
   char var[11];
   goto DOWN;
   ADDITION:              /////////ADDITION LABEL//////////////////////
  setcolor(WHITE);
  settextstyle(2,0,7);
  outtextxy(235,170,var);
  total=total+strtod(var,0);
  setcolor(BLACK);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(235,170,newvar);
  DOWN:      //////////////////DOWN LABEL//////////////////////
  Window w;    Mouse n;   Calculator c;  Submain s;
  Calculation cc;
   w.win();         c.calculator();
int i,o,button;     int xx=235,yy=170;  //START OF DIGITS ON SCREEN
int dgt=0;                       //ARRAY VAR'S VARIABLE
int check1=1;                           //CHECKS DOT COUNTING
int checkresult=0;
for ( ; ; )
{                                      //START OF FOR LOOP
n.position(&button,&i,&o);             // MOUSE INITIALIZATION
if ( (button &1)&&(i>=229 && i<=259) && (o>=380 && o<=410) )//ZERO
 {  c.anti0();
if(xx<=347)            //LIMIT OF DIGITS ON SCREEN
    {   if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(235,170,newvar);
     checkresult++;   }
    setcolor(BLACK);           settextstyle(2,0,7);
    outtextxy(xx,yy,"0");       var[dgt]='0';
    xx+=12;                     dgt++;
    }     delay(200);            c.calculator();
 }
if ( (button &1)&&(i>=274 && i<=304) && (o>=380 && o<=410) )//DOT
 { c.antidot();
 if(xx<=330 && check1%2!=0)   //ONCE ONLY DOT WILL BE PRINTED
  { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(235,170,newvar);
     checkresult++;   }
  setcolor(BLACK);             settextstyle(2,0,7);
  outtextxy(xx,yy,".");          var[dgt]='.';
  dgt++;       xx+=8;            check1++;
  }    delay(200);               c.calculator();
 }
 if ( (button &1)&&(i>=319 && i<=349) && (o>=380 && o<=410) )//EQUAL
 { c.antiequal();      delay(200);     c.calculator();
   setcolor(WHITE);    settextstyle(2,0,7);
   outtextxy(235,170,var);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(235,170,newvar);    xx=235;yy=170;  goto ADDITION;
 }
 if ( (button &1)&&(i>=364 && i<=394) && (o>=380 && o<=410) )//PLUS
 { c.antiplus();       delay(200);        c.calculator();
   xx=235;yy=170;   goto ADDITION;
  }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=335 && o<=365) )//ONE
  {  c.anti1();
  if(xx<=347)
   {  if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"1");
      var[dgt]='1';      dgt++;    xx+=12;
   }  delay(200);        c.calculator();
  }

 if ( (button &1)&&(i>=274 && i<=304) && (o>=335 && o<=365) )//TWO
  {  c.anti2();
   if(xx<=347)
    {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"2");
      var[dgt]='2';      dgt++;                xx+=12;
    } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=335 && o<=365) )//THREE
 {  c.anti3();
   if(xx<=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);    settextstyle(2,0,7);   outtextxy(xx,yy,"3");
     var[dgt]='3';       dgt++;                 xx+=12;
   } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=335 && o<=365) )//MINUS
 { c.antiminus();        delay(200);          c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.subtract(newvar);
}
 if ( (button &1)&&(i>=229 && i<=259) && (o>=290 && o<=320) )//FOUR
 { c.anti4();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"4");
    var[dgt]='4';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=290 && o<=320) )//FIVE
 {  c.anti5();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"5");
    var[dgt]='5';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=290 && o<=320) )//SIX
 {  c.anti6();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);    settextstyle(2,0,7);  outtextxy(xx,yy,"6");
    var[dgt]='6';       dgt++;                xx+=12;
  } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=290 && o<=320) )//MULT
 {  c.antimult();      delay(200);            c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.multiply(newvar);
 }
if ( (button &1)&&(i>=229 && i<=259) && (o>=245 && o<=275) )//SEVEN
 {  c.anti7();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"7");
    var[dgt]='7';      dgt++;                 xx+=12;
  } delay(200);        c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=245 && o<=275) )//EIGHT
  { c.anti8();
  if(xx<=347)
   { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);  settextstyle(2,0,7);   outtextxy(xx,yy,"8");
     var[dgt]='8';     dgt++;                 xx+=12;
   } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=245 && o<=275) )//NINE
  { c.anti9();
  if(xx <=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"9");
     var[dgt]='9';      dgt++;                xx+=12;
   } delay(200);        c.calculator();
  }
  if ( (button &1)&&(i>=364 && i<=394) && (o>=245 && o<=275) )//DIVISION
 {  c.antidivide();     delay(200);           c.calculator();
    gcvt(total, 3, newvar);  //CHANGES LONG TO STRING
    cc.divide(newvar);
 }
 if ( (button &1)&&(i>=609 && i<=621) && (o>=9 && o<=22) )//CLOSE
 {  w.anticlose();     delay(200);        exit(1); }

 if ( (button &1)&&(i>=363 && i<=393) && (o>=205 && o<=335) )//CE
 {  c.antiCE();           delay(200);        c.calculator();
  setcolor(WHITE);                    // CLEARS SCREEN
  settextstyle(2,0,7);    xx=235;yy=170;
  outtextxy(xx,yy,var);
  total=total+strtod(var,0);   setcolor(WHITE);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(xx,yy,newvar);
  var[dgt]=0;   dgt=0;   check1--;   //AGAIN SET CONDITION TO PRINT DOT
  s.submain();
 }
 if ( (button &2)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//ANTI_CREDIT
       { c.anticredit();  w.info();   }
 if ( (button &1)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//CREDIT
       {  c.credit();     w.anti_info(); }
} ////////////////////////END OF WHILE//////////////////////////////////
}        //////////////////END OF ADDITION FUNCTION////////////////*/
void Base::subtract(char*newvar)
{

   double total=atof(newvar);
   char var[11];    int xx=235,yy=170;  //START OF DIGITS ON SCREEN
   goto DOWN;
   SUBTRACTION:              /////////SUBTRACTION LABEL////////////////
  setcolor(WHITE);
  settextstyle(2,0,7);
  outtextxy(xx,yy,var);
  total=total-strtod(var,0);
  setcolor(BLACK);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(xx,yy,newvar);
  DOWN:      //////////////////DOWN LABEL//////////////////////
  Window w;    Mouse n;   Calculator c;  Submain s;
  Calculation cc;
   w.win();         c.calculator();
int i,o,button;
int dgt=0;                              //ARRAY VAR'S VARIABLE
int check1=1;                           //CHECKS DOT COUNTING
int checkresult=0;
for ( ; ; )
{                                      //START OF FOR LOOP
n.position(&button,&i,&o);             // MOUSE INITIALIZATION
if ( (button &1)&&(i>=229 && i<=259) && (o>=380 && o<=410) )//ZERO
 {  c.anti0();
if(xx<=347)            //LIMIT OF DIGITS ON SCREEN
    {   if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);           settextstyle(2,0,7);
    outtextxy(xx,yy,"0");       var[dgt]='0';
    xx+=12;                     dgt++;
    }     delay(200);            c.calculator();
 }
if ( (button &1)&&(i>=274 && i<=304) && (o>=380 && o<=410) )//DOT
 { c.antidot();
 if(xx<=330 && check1%2!=0)   //ONCE ONLY DOT WILL BE PRINTED
  { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
  setcolor(BLACK);             settextstyle(2,0,7);
  outtextxy(xx,yy,".");          var[dgt]='.';
  dgt++;       xx+=8;            check1++;
  }    delay(200);               c.calculator();
 }
 if ( (button &1)&&(i>=319 && i<=349) && (o>=380 && o<=410) )//EQUAL
 { c.antiequal();      delay(200);     c.calculator();
   setcolor(WHITE);    settextstyle(2,0,7);
    xx=235;yy=170;     outtextxy(xx,yy,var);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(xx,yy,newvar);    goto SUBTRACTION;
 }
 if ( (button &1)&&(i>=364 && i<=394) && (o>=380 && o<=410) )//PLUS
 { c.antiplus();       delay(200);        c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.addition(newvar);
  }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=335 && o<=365) )//ONE
  {  c.anti1();
  if(xx<=347)
   {  if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"1");
      var[dgt]='1';      dgt++;    xx+=12;
   }  delay(200);        c.calculator();
  }

 if ( (button &1)&&(i>=274 && i<=304) && (o>=335 && o<=365) )//TWO
  {  c.anti2();
   if(xx<=347)
    {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"2");
      var[dgt]='2';      dgt++;                xx+=12;
    } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=335 && o<=365) )//THREE
 {  c.anti3();
   if(xx<=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);    settextstyle(2,0,7);   outtextxy(xx,yy,"3");
     var[dgt]='3';       dgt++;                 xx+=12;
   } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=335 && o<=365) )//MINUS
 { c.antiminus();        delay(200);          c.calculator();
   xx=235;yy=170;       goto SUBTRACTION;
}
 if ( (button &1)&&(i>=229 && i<=259) && (o>=290 && o<=320) )//FOUR
 { c.anti4();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"4");
    var[dgt]='4';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=290 && o<=320) )//FIVE
 {  c.anti5();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"5");
    var[dgt]='5';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=290 && o<=320) )//SIX
 {  c.anti6();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);    settextstyle(2,0,7);  outtextxy(xx,yy,"6");
    var[dgt]='6';       dgt++;                xx+=12;
  } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=290 && o<=320) )//MULT
 {  c.antimult();      delay(200);            c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.multiply(newvar);
 }
if ( (button &1)&&(i>=229 && i<=259) && (o>=245 && o<=275) )//SEVEN
 {  c.anti7();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"7");
    var[dgt]='7';      dgt++;                 xx+=12;
  } delay(200);        c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=245 && o<=275) )//EIGHT
  { c.anti8();
  if(xx<=347)
   { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);  settextstyle(2,0,7);   outtextxy(xx,yy,"8");
     var[dgt]='8';     dgt++;                 xx+=12;
   } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=245 && o<=275) )//NINE
  { c.anti9();
  if(xx <=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"9");
     var[dgt]='9';      dgt++;                xx+=12;
   } delay(200);        c.calculator();
  }
  if ( (button &1)&&(i>=364 && i<=394) && (o>=245 && o<=275) )//DIVISION
 {  c.antidivide();     delay(200);           c.calculator();
    gcvt(total, 3, newvar);  //CHANGES LONG TO STRING
    cc.divide(newvar);
 }
 if ( (button &1)&&(i>=609 && i<=621) && (o>=9 && o<=22) )//CLOSE
 {  w.anticlose();     delay(200);        exit(1); }

 if ( (button &1)&&(i>=363 && i<=393) && (o>=205 && o<=335) )//CE
 {  c.antiCE();           delay(200);        c.calculator();
   var[dgt]=0;   dgt=0;   check1--;   //AGAIN SET CONDITION TO PRINT DOT
  setcolor(WHITE);                    // CLEARS SCREEN
  settextstyle(2,0,7);     xx=235;yy=170;
  outtextxy(xx,yy,var);
  total=total-strtod(var,0);   setcolor(WHITE);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(xx,yy,newvar);   s.submain();
 }
 if ( (button &2)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//ANTI_CREDIT
       { c.anticredit();  w.info();   }
 if ( (button &1)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//CREDIT
       {  c.credit();     w.anti_info(); }
} ////////////////////////END OF WHILE//////////////////////////////////
}        //////////////////END OF SUBTRACTION FUNCTION////////////////*/
void Base::multiply(char*newvar)
{

   double total=atof(newvar);
   char var[11], *endptr;
   int xx=235,yy=170;  //START OF DIGITS ON SCREEN
   goto DOWN;
   MULTIPLICATION:         ///////// MULTIPLICATION LABEL///////////////
   setcolor(WHITE);
   settextstyle(2,0,7);
   outtextxy(xx,yy,var);
   total=total*strtod(var,&endptr);
   setcolor(BLACK);
   settextstyle(2,0,7);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(xx,yy,newvar);
 DOWN:              ////////////DOWN LABEL//////////////////////
  Window w;    Mouse n;   Calculator c;  Submain s;
  Calculation cc;
   w.win();         c.calculator();
int i,o,button;
int dgt=0;                              //ARRAY VAR'S VARIABLE
int check1=1;                           //CHECKS DOT COUNTING
int checkresult=0;
for ( ; ; )
{                          ////////START OF  FOR LOOP ////////////
n.position(&button,&i,&o);             // MOUSE INITIALIZATION
if ( (button &1)&&(i>=229 && i<=259) && (o>=380 && o<=410) )//ZERO
 {  c.anti0();
if(xx<=347)            //LIMIT OF DIGITS ON SCREEN
    {   if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);           settextstyle(2,0,7);
    outtextxy(xx,yy,"0");       var[dgt]='0';
    xx+=12;                     dgt++;
    }     delay(200);            c.calculator();
 }
if ( (button &1)&&(i>=274 && i<=304) && (o>=380 && o<=410) )//DOT
 { c.antidot();
 if(xx<=330 && check1%2!=0 )   //ONCE ONLY DOT WILL BE PRINTED
  { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
  setcolor(BLACK);             settextstyle(2,0,7);
  outtextxy(xx,yy,".");          var[dgt]='.';
  dgt++;       xx+=8;            check1++;
  }    delay(200);               c.calculator();
 }
 if ( (button &1)&&(i>=319 && i<=349) && (o>=380 && o<=410) )//EQUAL
 { c.antiequal();      delay(200);     c.calculator();
   setcolor(WHITE);    settextstyle(2,0,7);
    xx=235;yy=170;     outtextxy(xx,yy,var);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(xx,yy,newvar);    goto MULTIPLICATION;
 }
 if ( (button &1)&&(i>=364 && i<=394) && (o>=380 && o<=410) )//PLUS
 { c.antiplus();       delay(200);        c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.addition(newvar);
  }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=335 && o<=365) )//ONE
  {  c.anti1();
  if(xx<=347)
   {  if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"1");
      var[dgt]='1';      dgt++;    xx+=12;
   }  delay(200);        c.calculator();
  }

 if ( (button &1)&&(i>=274 && i<=304) && (o>=335 && o<=365) )//TWO
  {  c.anti2();
   if(xx<=347)
    {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"2");
      var[dgt]='2';      dgt++;                xx+=12;
    } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=335 && o<=365) )//THREE
 {  c.anti3();
   if(xx<=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);    settextstyle(2,0,7);   outtextxy(xx,yy,"3");
     var[dgt]='3';       dgt++;                 xx+=12;
   } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=335 && o<=365) )//MINUS
 { c.antiminus();        delay(200);          c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.subtract(newvar);
}
 if ( (button &1)&&(i>=229 && i<=259) && (o>=290 && o<=320) )//FOUR
 { c.anti4();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"4");
    var[dgt]='4';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=290 && o<=320) )//FIVE
 {  c.anti5();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"5");
    var[dgt]='5';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=290 && o<=320) )//SIX
 {  c.anti6();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);    settextstyle(2,0,7);  outtextxy(xx,yy,"6");
    var[dgt]='6';       dgt++;                xx+=12;
  } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=290 && o<=320) )//MULT
 {  c.antimult();      delay(200);            c.calculator();
    xx=235;yy=170;    goto MULTIPLICATION;
 }
if ( (button &1)&&(i>=229 && i<=259) && (o>=245 && o<=275) )//SEVEN
 {  c.anti7();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"7");
    var[dgt]='7';      dgt++;                 xx+=12;
  } delay(200);        c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=245 && o<=275) )//EIGHT
  { c.anti8();
  if(xx<=347)
   { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);  settextstyle(2,0,7);   outtextxy(xx,yy,"8");
     var[dgt]='8';     dgt++;                 xx+=12;
   } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=245 && o<=275) )//NINE
  { c.anti9();
  if(xx <=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"9");
     var[dgt]='9';      dgt++;                xx+=12;
   } delay(200);        c.calculator();
  }
  if ( (button &1)&&(i>=364 && i<=394) && (o>=245 && o<=275) )//DIVISION
 {  c.antidivide();     delay(200);           c.calculator();
    gcvt(total, 3, newvar);  //CHANGES LONG TO STRING
    cc.divide(newvar);
 }
 if ( (button &1)&&(i>=609 && i<=621) && (o>=9 && o<=22) )//CLOSE
 {  w.anticlose();     delay(200);        exit(1);
 }
 if ( (button &1)&&(i>=363 && i<=393) && (o>=205 && o<=335) )//CE
 {  c.antiCE();           delay(200);        c.calculator();
  setcolor(WHITE);                    // CLEARS SCREEN
  settextstyle(2,0,7);     xx=235;yy=170;
  outtextxy(xx,yy,var);
  total=total*strtod(var,&endptr);   setcolor(WHITE);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(xx,yy,newvar);
  var[dgt]=0;   dgt=0;   check1--;   //AGAIN SET CONDITION TO PRINT DOT
  s.submain();
 }
 if ( (button &2)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//ANTI_CREDIT
       { c.anticredit();  w.info();   }
 if ( (button &1)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//CREDIT
       {  c.credit();     w.anti_info(); }
}           ///////////////////END OF FOR////////////////////////
}   //////////////////END OF MULTIPLY FUNCTION////////////////
void Base::divide(char*newvar)
{

   double total=atof(newvar);
   char var[11], *end;
   int xx=235,yy=170;  //START OF DIGITS ON SCREEN
   goto DOWN;
   DIVISION:         ///////// DIVISION LABEL///////////////
   setcolor(WHITE);
   settextstyle(2,0,7);
   outtextxy(xx,yy,var);
   total=total/strtod(var,&end);
   setcolor(BLACK);
   settextstyle(2,0,7);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(xx,yy,newvar);
 DOWN:              ////////////DOWN LABEL//////////////////////
  Window w;    Mouse n;   Calculator c;  Submain s;
  Calculation cc;
   w.win();         c.calculator();
int i,o,button;
int dgt=0;                              //ARRAY VAR'S VARIABLE
int check1=1;                           //CHECKS DOT COUNTING
int checkresult=0;
for ( ; ; )
{                          ////////START OF  FOR LOOP ////////////
n.position(&button,&i,&o);             // MOUSE INITIALIZATION
if ( (button &1)&&(i>=229 && i<=259) && (o>=380 && o<=410) )//ZERO
 {  c.anti0();
if(xx<=347)            //LIMIT OF DIGITS ON SCREEN
    {   if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);           settextstyle(2,0,7);
    outtextxy(xx,yy,"0");       var[dgt]='0';
    xx+=12;                     dgt++;
    }     delay(200);            c.calculator();
 }
if ( (button &1)&&(i>=274 && i<=304) && (o>=380 && o<=410) )//DOT
 { c.antidot();
 if(xx<=330 && check1%2!=0 )   //ONCE ONLY DOT WILL BE PRINTED
  { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
  setcolor(BLACK);             settextstyle(2,0,7);
  outtextxy(xx,yy,".");          var[dgt]='.';
  dgt++;       xx+=8;            check1++;
  }    delay(200);               c.calculator();
 }
 if ( (button &1)&&(i>=319 && i<=349) && (o>=380 && o<=410) )//EQUAL
 { c.antiequal();      delay(200);     c.calculator();
   setcolor(WHITE);    settextstyle(2,0,7);
    xx=235;yy=170;     outtextxy(xx,yy,var);
   gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
   outtextxy(xx,yy,newvar);    goto DIVISION;
 }
 if ( (button &1)&&(i>=364 && i<=394) && (o>=380 && o<=410) )//PLUS
 { c.antiplus();       delay(200);        c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.addition(newvar);
  }
 if ( (button &1)&&(i>=229 && i<=259) && (o>=335 && o<=365) )//ONE
  {  c.anti1();
  if(xx<=347)
   {  if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"1");
      var[dgt]='1';      dgt++;    xx+=12;
   }  delay(200);        c.calculator();
  }

 if ( (button &1)&&(i>=274 && i<=304) && (o>=335 && o<=365) )//TWO
  {  c.anti2();
   if(xx<=347)
    {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
      setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"2");
      var[dgt]='2';      dgt++;                xx+=12;
    } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=335 && o<=365) )//THREE
 {  c.anti3();
   if(xx<=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);    settextstyle(2,0,7);   outtextxy(xx,yy,"3");
     var[dgt]='3';       dgt++;                 xx+=12;
   } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=335 && o<=365) )//MINUS
 { c.antiminus();        delay(200);          c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.subtract(newvar);
}
 if ( (button &1)&&(i>=229 && i<=259) && (o>=290 && o<=320) )//FOUR
 { c.anti4();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"4");
    var[dgt]='4';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=290 && o<=320) )//FIVE
 {  c.anti5();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);     settextstyle(2,0,7);  outtextxy(xx,yy,"5");
    var[dgt]='5';        dgt++;                xx+=12;
  } delay(200);          c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=290 && o<=320) )//SIX
 {  c.anti6();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);    settextstyle(2,0,7);  outtextxy(xx,yy,"6");
    var[dgt]='6';       dgt++;                xx+=12;
  } delay(200);         c.calculator();
 }
if ( (button &1)&&(i>=364 && i<=394) && (o>=290 && o<=320) )//MULT
 {  c.antimult();      delay(200);            c.calculator();
    gcvt(total, 3, newvar);           //CHANGES LONG TO STRING
    cc.multiply(newvar);
 }
if ( (button &1)&&(i>=229 && i<=259) && (o>=245 && o<=275) )//SEVEN
 {  c.anti7();
  if(xx<=347)
  {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
    setcolor(BLACK);   settextstyle(2,0,7);   outtextxy(xx,yy,"7");
    var[dgt]='7';      dgt++;                 xx+=12;
  } delay(200);        c.calculator();
 }
if ((button&1)&&(i>=274 &&i<=304) && (o>=245 && o<=275) )//EIGHT
  { c.anti8();
  if(xx<=347)
   { if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);  settextstyle(2,0,7);   outtextxy(xx,yy,"8");
     var[dgt]='8';     dgt++;                 xx+=12;
   } delay(200);        c.calculator();
  }
if ( (button &1)&&(i>=319 && i<=349) && (o>=245 && o<=275) )//NINE
  { c.anti9();
  if(xx <=347)
   {if (checkresult==0)
   { setcolor(WHITE);     settextstyle(2,0,7);
     outtextxy(xx,yy,newvar);
     checkresult++;   }
     setcolor(BLACK);   settextstyle(2,0,7);  outtextxy(xx,yy,"9");
     var[dgt]='9';      dgt++;                xx+=12;
   } delay(200);        c.calculator();
  }
  if ( (button &1)&&(i>=364 && i<=394) && (o>=245 && o<=275) )//DIVISION
 {  c.antidivide();     delay(200);           c.calculator();
    xx=235;yy=170;    goto DIVISION;
 }
 if ( (button &1)&&(i>=609 && i<=621) && (o>=9 && o<=22) )//CLOSE
 {  w.anticlose();     delay(200);        exit(1);
 }
 if ( (button &1)&&(i>=363 && i<=393) && (o>=205 && o<=335) )//CE
 {  c.antiCE();           delay(200);        c.calculator();
  setcolor(WHITE);                    // CLEARS SCREEN
  settextstyle(2,0,7);     xx=235;yy=170;
  outtextxy(xx,yy,var);
  total=total/strtod(var,&end);   setcolor(WHITE);
  settextstyle(2,0,7);
  gcvt(total, 3, newvar);               //CHANGES LONG TO STRING
  outtextxy(xx,yy,newvar);
  var[dgt]=0;   dgt=0;   check1--;   //AGAIN SET CONDITION TO PRINT DOT
  s.submain();
 }
 if ( (button &2)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//ANTI_CREDIT
       { c.anticredit();  w.info();   }
 if ( (button &1)&&(i>=25 && i<=190) && (o>=145 && o<=170) )//CREDIT
       {  c.credit();     w.anti_info(); }
}           ///////////////////END OF FOR////////////////////////
}   //////////////////END OF DIVIDE FUNCTION////////////////
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment