Professional Documents
Culture Documents
Project name:-
scientific calculator
using c++
1
Scientific calculator using c++
ACKNOWLEDGEMENT :-
Quote
TABLE OF CONTENT:-
1.1 INTRODUCTION
1.2 LOGIC OF THE PROGRAMME:-
1.2.1. CREATING THE STANDARD CALCULATOR :-
1.2.2 CREATING SCIENTIFIC CALCULATOR:-
1.3 CONTROL DIAGRAM
1.4. SOURCE CODE OF SCIENTIFICCALCULATOR IN C++
1.5 OUTPUT SCREEN
1.5 1. Main Screen
1.5 3. Result screen:-
2
Scientific calculator using c++
1.1 INTRODUCTION
3
Scientific calculator using c++
FUNCTION DESCRIPTION
Addition returns the addition of two input number
Substraction returns the substraction of two number.
Multiplication returns the multiplication of two number.
Division returns the output obtained after perform
4
Scientific calculator using c++
You have to need to creat scientific calculator class to perform task related
toscientific calculations. Which include finding square or cube etc.The scientific
calculator perform following task.1 . D e t e r m i n e t h e s q u a r e o f t h e
n u m b e r . 2 . D e t e r m i n e t h e s q u a r e r o o t o f t h e n u m b e r 3.Determine the
first number power of the second number 4 . D e t e r m i n e t h e f a c t o r i a l o f
a number
5.Determine the sin, cos and tan value of the number.6.Determine the
logarithm, natural logarithm and exponential of thenumber.To perform the
above mentioned task in scientific calculator implements thefollowing member
function.
FUNCTION DESCRIPTION
Square accept a number and returns the square of the number
Squae root accept a number and returns the square root of number
Cube accept two number and returns the first power to 2ndnu
5
Scientific calculator using c++
6
Scientific calculator using c++
7
Scientific calculator using c++
8
Scientific calculator using c++
}
double scien_calc::cos_fun(double x)
{
return(cos(x));
}
double scien_calc::tan_fun(double x)
{
return(tan(x));
}
double scien_calc::log_fun(double x)
{
return(log(x));
}
double scien_calc::log10_fun(double x)
{
return(log10(x));
}
double scien_calc::exp_fun(double x)
{
return(exp(x));
}
double scien_calc::sqrt_fun(double x)
{
return(sqrt(x));
}
void main()
{
double num1,num2,num3,temp;
int choice1=0,choice2,flag;
do
{
clrscr();
cout<<"==================type of calculator======================";
cout<<"\n1\tStandard calculator \n2\tScientific calculator\n3\tQuit";
cout<<"\n choose type of the calculator";
cin>>choice1;
flag=new_calc;
switch(choice1)
{
case 1:do
{
clrscr();
cout<<"====================standard calculator=====================";
cout<<"\n1\taddition\n2\tsubstraction\n3\tmultiplication\n4\tdivision\n5\tmodulus\n6\treturn to
previous menu\n7\tquit";
9
Scientific calculator using c++
if(flag==old_calc)cout<<"\n8\tclear memory";
cout<<"\nchoose type of the calculation:";
cin>>choice2;switch(choice2)
{
case 1:if(flag==new_calc)
{
cout<<"enter the first number:";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nfirst number is "<<num1<<endl;
}
cout<<"enter the secondnumber:";
cin>>num2;
num3=stand_calc::addition(num1,num2);
cout<<"\naddition of "<<num1<<"+"<<num2<<"="<<num3;
cout<<"\npress any key to continue...................";
getch();
temp=num3;
flag=old_calc;
break;
case 2:if(flag==new_calc)
{
cout<<"enter the first number";
cin>>num1 ;
}
Else
{
num1=temp;
cout<<"\nfirst number is"<<num1<<endl;
}
cout<<"enter second number:";
cin>>num2;
num3=stand_calc::substract(num1,num2);
cout<<"\nsubstraction of "<<num2<<"-"<<num1<<"="<<num3;
cout<<"\npress any key to continue..................";
getch();
temp=num3;
flag=old_calc;
break;
case 3:
if(flag==new_calc)
{
10
Scientific calculator using c++
11
Scientific calculator using c++
}
cout<<"enter the second number:";
cin>>num2;
num3=stand_calc::modulus(&num1,&num2);
cout<<"\nmodulus of "<<num1<<"by "<<num2<<"is"<<num3;
cout<<"press any key to continue...............";
getch();
temp=num3;
flag=old_calc;
break;
case 6:cout<<"\nreturning to previous menu";
cout<<"\npress any key to continue................";
getch();
break;
case 7:cout<<"\n quitting.................";
cout<<"\npress any key to continue...........";
getch();
exit(0);
case 8:if(flag==new_calc)
{
cout<<"\ninvalid choice";
cout<<"\npress any key to continue............";
getch();
}
Else
{
temp=0;
flag=new_calc;
}
break;
default:cout<<"\ninvalid choice";
cout<<"\npress any key to continue..............";
getch();
break;
}
}
while(choice2!=6);
break;
case 2:do
{
clrscr();
cout<<"=============Scientific calculator===============";
cout<<"\n1\tsquare\n2\tsquareroot\n3\tcube\n4\tpower\n5\tfactorial\n6\tsin\n7\tcos\n8\ttan\n9\
tlogrithm\n10\tnatural logrithm\n11\texponential\n12\treturn to previousmenu\n13\tquit";
if(flag==old_calc)
12
Scientific calculator using c++
{
cout<<"\n14\tclear memory";
cout<<"\n choose type of the calculation :";
cin>>choice2;
switch(choice2)
{
case 1:if(flag==new_calc)
{
cout<<"enter number to find square :";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\n number is "<<num1<<endl;
}
num3=scien_calc::square(num1);
cout<<"\nsquare of "<<num1<<"="<<num3;
cout<<"\npress any key to continue.............";
getch();
temp=num3;
flag=old_calc;
break;
case 2:if(flag==new_calc)
{
cout<<"enter number to find square root :";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\n number ="<<num1<<endl;
}
num3=scien_calc::sqrt_fun(num1);
cout<<"\nsquare of "<<num1<<"="<<num3;
cout<<"\npress any key to continue.............";
getch();
temp=num3;
flag=old_calc;
break;
case 3:if(flag==new_calc)
{
cout<<"enter to find cube";
cin>>num1;
}
13
Scientific calculator using c++
Else
{
num1=temp;
cout<<"\nnumber is "<<num1<<endl;
}
num3=scien_calc::cube(num1);
cout<<"\ncube of"<<num1<<"="<<num3;
cout<<"\npress any key to continue..........";
getch();
temp=num3;
flag=old_calc;
break;
case 4:if(flag==new_calc)
{
cout<<"enter the first number of base to find power";cin>>num1;
}
Else
{
num1=temp;
cout<<"\nfirst number is"<<num1<<endl;
}
cout<<"enter the second number for for to find power:";
cin>>num2;
num3=scien_calc::power(num1,num2);
cout<<"\n"<<num1<<"^"<<num2<<"="<<num3;
cout<<"\npress any key to continue............";
getch();
temp=num3;
flag=old_calc; break;
case 5:if(flag==new_calc)
{
cout<<"enter number to find factorial:";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\n number to find factorial is"<<num1<<endl;
}
long int num4=scien_calc::fact(num1);
cout<<"\nfactorial of"<<num1<<" = "<<num4;
cout<<"\npress any key to continue...............";
getch();
temp=num4;
flag=old_calc;
14
Scientific calculator using c++
break;
case 6:if(flag==new_calc)
{
cout<<"enter SIN ";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nnumber for sin value is"<<num1<<endl;
}
num3=scien_calc::sin_fun(num1);
cout<<"\nSIN"<<num1<<" = "<<num3;
cout<<"\npress any key to continue..............";
getch();
temp=num3;
flag=old_calc;
break;
case 7:if(flag==new_calc)
{
cout<<"\nenter COS ";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nnumber for cos value"<<num1<<endl;
}
num3=scien_calc::cos_fun(num1);
cout<<"\nCOS "<<num1<<"="<<num3;
cout<<"\npress any key to continue................";
getch();
temp=num3;
flag=old_calc;
break;
case 8:if(flag==new_calc)
{
cout<<"enter TAN ";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nnumber for tan value"<<num1<<endl;
}
15
Scientific calculator using c++
num3=scien_calc::tan_fun(num1);
cout<<"\nTAN "<<num1<<"="<<num3;
cout<<"\npress any key to continue..............";
getch();
temp=num3;
flag=old_calc;
break;
case 9:if(flag==new_calc)
{
cout<<"enter LOG :";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nnumber for log value"<<num1<<endl;
}
num3=scien_calc::log_fun(num1);
cout<<"\nLOG "<<num1<<"="<<num3;
cout<<"\npress any key to continue.................";
getch();
temp=num3;
flag=old_calc;
break;
case 10:if(flag==new_calc)
{
cout<<"enter LOG10 :";
cin>>num1;
}
Else
{
num1=temp;
cout<<"\nnumber for natural log value"<<num1<<endl;
}
num3=scien_calc::log10_fun(num1);
cout<<"\nLOG10 "<<num1<<"="<<num3;
cout<<"\npress any key to continue.................";
getch();
temp=num3;
flag=old_calc;
break;
case 11:if(flag==new_calc)
{
cout<<"enter e^ :";
cin>>num1;
16
Scientific calculator using c++
}
Else
{
num1=temp;
cout<<"\nnumber for exponential value"<<num1<<endl;
}
num3=scien_calc::exp_fun(num1);
cout<<"\ne^"<<num1<<"="<<num3;
cout<<"\npress any key to continue.................";
getch();
temp=num3;
flag=old_calc;
break;
case 12:cout<<"\nreturning to previous menu";
cout<<"\npress any key to continue.............";
getch();
break;
case 13:cout<<"\nQuitting..............";
cout<<"\npress any key to continue...............";
getch();
exit(0);
case 14:if(flag==new_calc)
{
cout<<"\ninvalid choice";
cout<<"\npress any key to continue.................";
getch();
}
Else
{
temp=0;
flag=new_calc;
}
break;
default:cout<<"invalid choice";
cout<<"press any key to continue...............";
getch();
break;
}
}
while(choice2!=13);
break;
case3:cout<<"\nQuitting..............";
cout<<"\npress any key to continue.............";
getch();
break;
17
Scientific calculator using c++
default:
cout<<"\ninvalid choice";
cout<<"\n press any key to continue.............";
getch();
break;
}
}
while(choice1!=3);
}
1.5.OUTPUT SCREEN
18
Scientific calculator using c++
19
Scientific calculator using c++
20
Scientific calculator using c++
21
Scientific calculator using c++
Thank you!
22