Professional Documents
Culture Documents
CSE202
DOA:
DOP:
Reg.No. 10900472
Class. B.Tech.-IT
Section:- D2901
INDEX
ACKNOWLEDGEMENT
INTRODUCTION
BASIC FUNCTIONS
SOURCE CODE
SCREEN SHOTS
REFERENCE
ACKNOWLEDGEMENT
Hereby, I would like to take the opportunity to thank a no. of people who helped me out in my
hour of need. Specially, my friends and roomies. These people really took a toll while working
with me on this term-paper and helping me out when I was really struck at times. Sincere ,
thanks to our library staff, who always provided us with their deep knowledge on various
subjects and books. And specially, to our subject teacher, who was always available with his
kind remarks and suggestions.
INTRODUCTION:-
Scientific Calculator
The calculator was written by Rolf Howarth in early 1996. A fully featured scientific calculator
with proper operator precedence is implemented, including trig functions and logarithms,
factorials, 12 levels of parentheses, logs to base 2 (a handy function for information entropists!),
bitwise logical operators, hex, octal, binary and ASCII display.The calculator is written in
JavaScript and you are welcome to view the JavaScript source (visible within the HTML page)
for personal educational purposes as long as you recognize that it is copyrighted and not in the
public domain. This calculator is now available as part of Hummingbird's Enterprise Information
Portal. All enquiries regarding licensing the calculator should be directed to Hummingbird Ltd.
Basic Functions:-
Addition
The addition (sum function) is used by clicking on the "+" button or using the keyboard.
The function results in a+b.
Subtraction
The subtraction (minus function) is used by clicking on the "-" button or using the
keyboard. The function results in a-b.
Multiplication
The multiplication (times function) is used by clicking on the "x" button or using the
keyboard "*" key. The function results in a*b.
Division
The division (divide function) is used by clicking on the "/" button or using the keyboard
"/" key. The function results in a/b.
Sign
The sign key (negative key) is used by clicking on the "(-)" button. The function results
in -1*x.
Square
The square function is used by clicking on the "x^2" button or type "^2". The function
results in x*x.
Square Root
The square root function is used by clicking on the "x" button or type "sqrt()". This
function represents x^.5 where the result squared is equal to x.
Raise to the Power
The raise to the power (y raised to the x function) is used by clicking on the "y^x" button
or type "^".
Natural Exponential
The natural exponential (e raised to the x) is used by clicking on the "e^x" button or type
"exp()". The result is e (2.71828...) raised to x.
Logarithm The logarithm (LOG) is used by clicking on the "LOG" button or type
"LOG()".
Natural Logarithm
The Natural logarithm (LN) is used by clicking on the "LN" button or type "LN()".
SOURCE CODE:-
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<process.h>
#include<stdlib.h>
#include<stdio.h>
class calc
{
public:
int i;
char q,ans;
float rt;
float result;
float value1,value2;
void disp();
void gdata1();
void gdata2();
void opdata();
void caldata();
};
void calc::gdata1()
{
cout<<"\nEnter the 1st value= ";
cin>>value1;
}
void calc::gdata2()
{
cout<<"\nEnter the 2nd value= ";
cin>>value2;
}
void calc::opdata()
{
cout<<"\nEnter the operator= ";
cin>>q;
}
void calc::caldata()
{
do
{
disp();
if(ans=='y'||ans=='Y')
value1=result;
else
gdata1();
opdata();
if(q=='+'||q=='-'||q=='*'||q=='/'||q=='x'||q=='@')
gdata2();
switch (q)
{
case '+' :
result=value1+value2;
break;
case '-' :
result=value1-value2;
break;
case '*' :
result=value1*value2;
break;
case '/' :
result=value1/value2;
break;
case 's' :
result=sin(value1);
break;
case 'c' :
result=cos(value1);
break;
case 't' :
result=tan(value1);
break;
case 'e' :
result=exp(value1);
break;
case 'r' :
result=sqrt(value1);
break;
case 'x' :
result=pow(value1,value2);
break;
case 'l' :
result=log(value1);
break;
case 'a' :
result=log10(value1);
break;
case 'd':
result=(value1*3.14)/180;
break;
case '$':
result=(value1*180)/3.14;
break;
case 'h':
result=sinh(value1);
break;
case 'n':
result=tanh(value1);
break;
case 'o':
result=cosh(value1);
break;
case '!':
result=pow10(value1);
break;
case '@':
result=((log(value1))/(log(value2)));
break;
case 'f':
result=1;
for(rt=1;rt<=value1;rt++)
{
result=result*rt;
}
break;
default :
i=2+1;
cout<<" W R O N G O P T I O N ";
}
if(i==3)
{
cout<<"\nSYNTAX ERROR";
}
else
{
cout<<"\nRESULT="<<result;
}
cout<<"\n\nDo you want to continue\n Enter y to carry on with the same
calculation\n or Enter r to reset the values\n or enter any other key to exit\t";
cin>>ans;
}while((ans=='y'||ans=='Y'||ans=='R'||ans=='r'));
}
void calc::disp()
{
clrscr();
cout<<"\n#######################SCIENTIFIC
CALCULATOR###########################\n";
cout<<"\n----------------------------OPERATION ---------------------------------------";
cout<<"\n-----------------------------------------------------------------------------";
cout<<"\n To perform Calculation Please Enter the Symbols GIVEN below\n";
cout<<"\n-----------------------------------------------------------------------------";
cout<<"\nADD= '+'\tSUB= '-'\tMUL= '*'\tDIVIDE= '/'
\tSIN='s'\nCOS='c'\t\tTAN='t'\t\tlog='l'\t\tSqrrt='r'";
cout<<"\tFact='f'\nEXP='e'\t\tDEGtoRad='d'\tln='a'\t\tX^Y='x'\t\ttanh='n' ";
cout<<"\nSinh='h'\tcosh='o'\tAnti log='!' ";
cout<<"\tRadtoDeg='$'\tlog m base n='@'";
cout<<"\n-----------------------------------------------------------------------------";
cout<<"\n-----------------------------------------------------------------------------";
}
int main()
{
calc b;
b.caldata();
return 0;
}
SCREEN SHOTS:-
Screen1:-
Screen2:-
Screen3:-
REFERENCES:-