Vous êtes sur la page 1sur 14

#include <iostream>

#include <conio.h>
#include <math.h>
using namespace std;
const double pi=3.141592655358;
class boardofcalc
{
public:
void board()
{
cout<<"what do you want to find ? Enter "<<endl
//board of scientifc calculater
<<" //////////////////////////////////////"<<endl
<<"|||
|||"<<endl
<<"|||
|||"<<endl
<<" /////////////////////////////////////"<<endl
<<" + "<<"|"<<" - "<<"|"<<" * "<<"|"<<" / "<<"|"<<" 1 "<<"|"<<" 2 "<<"|"<<" 3 "<
<"|"<<endl
<<"============================"<<endl
<<" S "<<"|"<<" C "<<"|"<<" T "<<"|"<<" I "<<"|"<<" 4 "<<"|"<<" 5 "<<"|"<<" 6 "<
<"|"<<endl
<<"============================"<<endl
<<" p "<<"|"<<" s "<<"|"<<" L "<<"|"<<" = "<<"|"<<" 7 "<<"|"<<" 8 "<<"|"<<" 9 "<
<"|"<<endl
<<"============================"<<endl
<<
" P "<<"|"<<" . "<<"|"<<" 0 "<<"|"<<" = "<
<"|" ;
}
void explain()
{
cout<<endl<<endl;
//explainanntion of operators
cout<<"IN ABOVE BOARD........"<<endl
<<" + =For three kinds of addition Normal, Complex ,Fraction "<<endl
<<" - =For three kinds of subtraction Normal, Complex ,Fraction "<<endl
<<" * =For three kinds of multiplication Normal, Complex ,Fraction "<<endl
<<" / =For three kinds of division Normal, Complex ,Fraction "<<endl
<<" S =Sin of number "<<endl<<" C =Cos of number "<<endl
<<" T=Tan of number "<<endl<<"small 'p' =Power of number (Normal and Fraction Nu
mbers) "<<endl
<<" I=Inverse of Sin Cos and Tan "<<endl<<"small 's' =Square root of number "<<e
ndl
<<" P=capital 'P' for percentage "<<endl<<" L =For (Natural and Base10 log) ";
}
};
class calculation : public boardofcalc
//In this class calculations of Norm
al numbrers are done
{
private:
double num1,num2,num3;
public:
////////////////////////////////////////////////////////////////////////////////
void addition()
//definition of addition function
{
double number;
num3=0;
cout<<"enter 1st number = ";
//getting input from user
cin>>num1;
cout<<"enter 2nd number = ";
cin>>num2;

num3=num1+num2;
cout<<"Addition is = "<<num3;
//priting result
cout<<endl<<endl;
cout<<"how many more numbers you will add to the result = ";
//asking for mo
re addition
cin>>number;
for(int i=1;i<=number;i++)
{
cout<<endl;
cout<<"enter number = ";
cin>>num1;
num3=num3+num1;
cout<<"Addition is = "<<num3;
}
}
////////////////////////////////////////////////////////////////////////////////
void subtraction()
//definition of subtraction func
tion
{
double number;
num3=0;
cout<<"enter 1st number = ";
cin>>num1;
//getting input from user
cout<<"enter 2nd number = ";
cin>>num2;
num3=num1-num2;
cout<<"subtraction is = "<<num3;
cout<<endl<<endl;
cout<<"how many more numbers you will subtract to the result = ";
//asking
for more subtraction
cin>>number;
for(int i=1;i<=number;i++)
{
cout<<endl;
cout<<"enter number = ";
cin>>num1;
num3=num3-num1;
cout<<"Subtraction is = "<<num3;
}
}
////////////////////////////////////////////////////////////////////////////////
void multiply()
//definition of multiplicatio
n function
{
double number;
num3=1;
cout<<"enter 1st number = "; //getting input
cin>>num1;
cout<<"enter 2nd number = ";
cin>>num2;
num3=num1*num2;
cout<<"Mutiplication is = "<<num3;
cout<<endl<<endl;

//printing result

//telling user that


he wants more multiplication with that number or not
cout<<"how many more numbers you will multiply to the result = ";
cin>>number;
ng input
for(int i=1;i<=number;i++)
{
cout<<endl;

//getti

cout<<"enter number = ";


cin>>num1;
num3=num3*num1;
cout<<"Multiplication is = "<<num3;

//printing result

}
}
////////////////////////////////////////////////////////////////////////////////
void division()
//
{
double number;
num3=1;
cout<<"enter 1st number = ";
cin>>num1;

//getting input from user

cout<<"enter 2nd number = ";


cin>>num2;
num3=num1/num2;
cout<<"Division is = "<<num3;

//printing result

cout<<endl<<endl;
cout<<"how many more numbers you will division to the result = "; //telling u
ser that he wants more division with that number or not
cin>>number;
for(int i=1;i<=number;i++)
{
//getting input from
user
cout<<endl;
cout<<"enter number = ";
cin>>num1;

//calculations

num3=num3/num1;
cout<<"Division is = "<<num3;

//printing result

}
}
////////////////////////////////////////////////////////////////////////////////
void power()

{
cout<<"enter number = ";
cin>>num1;

//getting input from user

cout<<"enter power which you wnat = ";


cin>>num2;
num3=1;
for(int i=1;i<=num2;i++)
{
num3=num3*num1;
}
cout<<"Power is = "<<num3;
//printing power of number
}
////////////////////////////////////////////////////////////////////////////////
void squareroot()
{
cout<<"enter number = ";
cin>>num1;

//getting input from user

num2=sqrt(num1);
cout<<"square root is = "<<num2;
}
void base10log()
{
cout<<"enter number = ";
cin>>num1;

//printing square root

//getting input from user

num2=log10(num1);
cout<<"Answer is = "<<num2;

//printing base10 log

}
void naturallog()
{
cout<<"enter number = ";
cin>>num1;

//getting input from user

num2=log(num1);
cout<<"Answer is = "<<num2;
}

//printing log

void percentage()
{
cout<<"enter number for which you want percentage = ";
cin>>num1;
ser
cout<<"enter number in which you want percentage = ";
cin>>num2;
num3=(num1*100)/num2;

//getting input from u

cout<<"Percentage is = "<<num3;
}

//printing percentage

};
////////////////////////////////////////////////////////////////////////////////
//END OF CLASS CALCULATIONS CLASS
////////////////////////////////////////////////////////////////////////////////
//BEGINING OF TRIGONOMETRY CLASS
////////////////////////////////////////////////////////////////////////////////
class trignometry
{
private:
double num1,num2;
public:
////////////////////////////////////////////////////////////////////////////////
void fsin()
//definition of sin functionn
{
cout<<"enter the number for which you want sin = ";
cin>>num1;
num2=sin(num1*pi/180.0);
cout<<"sin is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
void fcos()
{
cout<<"enter number = ";
cin>>num1;

//definition of cos function

num2=cos(num1*pi/180.0);
cout<<"cos is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
void ftan()
//definition of tan function
{
cout<<"enter number = ";
cin>>num1;
num2=tan(num1*pi/180);
cout<<"Tan is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
//definition of inverse of sin function
void invrsin()
{

cout<<"enter number = ";


cin>>num1;
num2=asin(num1)*180.0/pi;
cout<<"inverse of sin is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
void invrcos()
//definition of inverse of cos functio
n
{
cout<<"enter number = ";
cin>>num1;
num2=acos(num1)*180.0/pi;
cout<<"inverse of cos is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
void invrtan()
ction
{

//definition of inverse of tan fun

cout<<"enter number = ";


cin>>num1;
num2=atan(num1)*180.0/pi;
cout<<"inverse of tan is = "<<num2;
}
////////////////////////////////////////////////////////////////////////////////
};
////////////////////////////////////////////////////////////////////////////////
//END OF CLASS TRIGNOMETRY CLASS
////////////////////////////////////////////////////////////////////////////////
//BEGINING OF CLASS FRACTION CLASS
////////////////////////////////////////////////////////////////////////////////
class fraction
{
private:
double num1,num2,num3,num4,tot1,tot2,tot3,tot4,pow;
char ch;
public:
////////////////////////////////////////////////////////////////////////////////

void fadd()
//definition of finding additio of fra
ction numbers function
{
cout<<"enter 1st number in (Y/X) form = ";
//getting input from user
cin>>num1>>ch>>num2;
cout<<"enter 2nd number = ";
cin>>num3>>ch>>num4;
tot1=num1*num4;
tot2=num2*num3;
tot3=num2*num4;

//making calculation

tot4=tot1+tot2;
cout<<"Answer is = "<<tot4<<ch<<tot3;
//printing Answers
}
////////////////////////////////////////////////////////////////////////////////
/
void fsub()
//defintion o
f finding subtraction of fraction number function
{
cout<<"enter 1st number in (Y/X) form = ";
//getting input from
user
cin>>num1>>ch>>num2;
cout<<"enter 2nd number = ";
cin>>num3>>ch>>num4;
tot1=num1*num4;
tot2=num2*num3;
tot3=num2*num4;
tot4=tot1-tot2;

//making calculation

cout<<"Answer is = "<<tot4<<ch<<tot3;
//printing Answers
}
////////////////////////////////////////////////////////////////////////////////
void fmult()
//defintion of fi
nding multiplication of fraction number function
{
cout<<"enter 1st number in (Y/X) form = ";
cin>>num1>>ch>>num2;
//getting input from user
cout<<"enter 2nd number = ";
cin>>num3>>ch>>num4;
tot1=num1*num3;
tot2=num2*num4;

//printing Answers

cout<<"Answer is = "<<tot1<<ch<<tot2;

//printing Answers

}
////////////////////////////////////////////////////////////////////////////////
void fdivi()
//defintion of finding di
vision of fraction number function
{

cout<<"enter 1st fraction number = ";


cin>>num1>>ch>>num2;

//getting input from user

cout<<"enter 2nd fraction number = ";


cin>>num3>>ch>>num4;
//printing Answers
tot1=num1*num4;
tot2=num2*num3;
cout<<"Answer is = "<<tot1<<ch<<tot2;

//printing Answers

}
////////////////////////////////////////////////////////////////////////////////
void fpower()
power of fraction number
{
double i;
num3=1;
num4=1;

//defintion of finding
function

cout<<"enter number in fraction = ";


cin>>num1>>ch>>num2;

//getting input from user

cout<<"enter power = ";


cin>>pow;
for(i=1;i<=pow;i++)
{
num3=num3*num1;
}

//printing Answers

for(i=1;i<=pow;i++)
{
num4=num4*num2;
}
cout<<"power of that is = "<<num3<<ch<<num4;

//printing Answers

}
////////////////////////////////////////////////////////////////////////////////
};
////////////////////////////////////////////////////////////////////////////////
//END OF CLASS FRACTION
////////////////////////////////////////////////////////////////////////////////
//BEGINING OF CLASS COMPLEX
////////////////////////////////////////////////////////////////////////////////
class complex
{
private:
double num1,num2,num3,num4,tot1,tot2,tot3,tot4;
char ch,i;
public:

void cadd()
bers addition
{

//definition of funtion of comlex num

cout<<"enter complex number in (a+bi) format = "; //getting input in a+bi form
cin>>num1>>ch>>num2>>i;
cout<<"enter 2nd number = ";
cin>>num3>>ch>>num4>>i;
tot1=num1+num3;
tot2=num2+num4;
cout<<"answer is = "<<tot1<<ch<<"("<<tot2<<")"<<i;

//printing answer

}
////////////////////////////////////////////////////////////////////////////////
void csub()
{
//definition of complex subtr
action function
cout<<"enter 1st complex number = ";
cin>>num1>>ch>>num2>>i;
cout<<"enter 2nd complex number = ";
cin>>num3>>ch>>num4>>i;
tot1=num1-num3;
tot2=num2-num4;
cout<<"answer for subtration is = "<<tot1<<ch<<"("<<tot2<<")"<<i;
ting answer

//prin

}
///////////////////////////////////////////////////////////////////////////////
void cmult()
//definition of complex multiplicati
on function
{
cout<<"enter 1st complex number = ";
cin>>num1>>ch>>num2>>i;
//getting input
cout<<"enter 2nd complex number = ";
cin>>num3>>ch>>num4>>i;
tot1=(num1*num3)+(-(num2*num4));
tot2=(num1*num4)+(num2*num3);
cout<<"your answer in multipication is = "<<tot1<<ch<<"("<<tot2<<")"<<i;//printi
ng answer
}
////////////////////////////////////////////////////////////////////////////////

void cdivi()
{
sion function

//definition of complex divi

cout<<"enter 1st complex number = ";


cin>>num1>>ch>>num2>>i;
cout<<"enter 2nd complex number = ";
cin>>num3>>ch>>num4>>i;
tot1=(num1*num3)+(num2*(-num4));
tot2=(num1*(-num4))+(num2*num3);
tot3=(num3*num3)-(num4*(-num4));
cout<<"your answer in division is = "<<tot1<<ch<<"("<<tot2<<i<<")"<<"/"<<tot3;
//printing answer
}
////////////////////////////////////////////////////////////////////////////////
};
////////////////////////////////////////////////////////////////////////////////
//END OF CLASS COMPLEX
////////////////////////////////////////////////////////////////////////////////
//BEGINING OF MAIN
////////////////////////////////////////////////////////////////////////////////
main()
{
calculation c1;
trignometry t1;
fraction f1;
complex co1;

//Object of calculation class is created


//Object oftrignometry class is created
//object of fraction class is created
//object of complex class is created

char choice,choice1;
//decleration of variables
char ct,ct1,ct2,ct3,ct4,ct5; //ct=choice type
////////////////////////////////////////////////////////////////////////////////
do
//do while loop starts
{
cout<<endl;
c1.board();
//calling to board function of boardofcal class
c1.explain();
// calling to explain function of boardofcal class
cout<<endl<<"__________________________________________________________"<<endl
<<"__________________________________________________________"<<endl<<endl;
cout<<"Enter operator = ";
//getting operator from users
cin>>choice;
////////////////////////////////////////////////////////////////////////////////
if(choice=='+')
//checking operator
{
cout<<"what type of addition do you want N(normal),F(fraction),C(complex) = ";
cin>>ct;

if(ct=='N'||ct=='n')
{
on class
c1.addition();
}
else if(ct=='F'||ct=='f')
{
f1.fadd();
class
}

//calling to addition function of calculati

//calling to addtion function of fraction

else if(ct=='C'||ct=='c')
{
co1.cadd();
class
}
else
{
cout<<"invlaid entry!!!!!!!!!!!!!";
}
}

//calling to addition function of comlex

////////////////////////////////////////////////////////////////////////////////
else if(choice=='-')
{
cout<<"what type of subtraction do you want N(normal),F(fraction),C(complex) = "
;
cin>>ct1;
if(ct1=='N'||ct1=='n')
{
//calling to subtraction function of calcula
tion class
c1.subtraction();
}
else if(ct1=='F'||ct1=='f')
{
f1.fsub();
on class
}

//calling to subtraction function of fracti

else if(ct=='C'||ct=='c')
{
co1.csub();
//calling to subtraction function of comle
x class
}
}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='*')
{
cout<<"what type of multiplication do you want N(normal)"<<endl<<"F(fraction),C(
complex) = ";
cin>>ct2;
if(ct2=='N'||ct2=='n')
{
c1.multiply();
//calling to multiplication function

of calculation class
}
else if(ct2=='F'||ct2=='f')
{
f1.fmult();
fraction class
}

//calling to multiplication function of

else if(ct2=='C'||ct2=='c')
{
co1.cmult();
mlex class
}
}

//calling to multiplication function of co

////////////////////////////////////////////////////////////////////////////////
else if(choice=='/')
{
cout<<"what type of division do you want N(normal)"<<endl<<"F(fraction),C(comple
x) = ";
cin>>ct3;
if(ct3=='N'||ct3=='n')
{
c1.division();
lation class
}

//calling to division function of calcu

else if(ct3=='F'||ct3=='f')
{
f1.fdivi();
ion class
}

//calling to division function of fract

else if(ct3=='C'||ct3=='c')
{
//calling to division function of comp
lex class
co1.cdivi();
}
}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='p')
{
cout<<"enter what type of numbers power do you want N(normal),"<<endl<<"F(fracti
on) = ";
cin>>ct4;
if(ct4=='N'||ct4=='n')
{
c1.power();
//calling to power function of calculat
ion class
}
else if(ct4=='F'||ct4=='f')

{
f1.fpower();
on class
}

//calling to power function of fracti

}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='s')
{
c1.squareroot();
of calculation class
}

//calling to square root function

////////////////////////////////////////////////////////////////////////////////
else if(choice=='L'||choice=='l')
{
cout<<"what type of log do you want N(Natural log) L(base10 log) = ";
cin>>ct5;
if(ct5=='N')
{
c1.naturallog();
ass
}

//calling to natural log function of calculatoin cl

else if(ct5=='L'||ct5=='l')
{
c1.base10log();
//calling to base10 log function of calculatoin class
}
}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='P')
{
c1.percentage();
//calling to percentage function of calculation class
}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='S')
{
t1.fsin();
}
//calling to sin function of trignometry class
////////////////////////////////////////////////////////////////////////////////
else if(choice=='C'||choice=='c')
{
t1.fcos();
//calling to cos function of trignometric class
}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='T'||choice=='t')
{
t1.ftan();
//calling to tan function of trignometric cla
ss

}
////////////////////////////////////////////////////////////////////////////////
else if(choice=='I'|| choice=='i')
{
cout<<"For which you want inverse enter S for sine, C for cos, T for tan = ";
cin>>ct2;
if(ct2=='S'||ct2=='s' )
{
ry class
t1.invrsin();
}

//calling to inverse sin function of trignomet

else if(ct2=='C'||ct2=='c')
{
t1.invrcos();
ric class
}

//calling to inverse cos function of trignomet

else if(ct2=='T'||ct2=='t')
{
t1.invrtan();
nometric class
}
}

//calling to inverse tan function of trig

////////////////////////////////////////////////////////////////////////////////
cout<<endl<<endl;
////////////////////////////////////////////////////////////////////////////////
cout<<"-----------------------------------------------------------------------"<
<endl<<endl;
cout<<"Do you want more calculations = ";
cin>>choice1;
if(choice1!='y'&& choice1!='n')
{
cout<<"you have entered wrong choice!!!!!!!!!!";
}
}while(choice1!='n');
////////////////////////////////////////////////////////////////////////////////
getch();
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// END

OF

PROGRAM

////////////////////////////////////////////////////////////////////////////////

Vous aimerez peut-être aussi