Scientific Calculator In
C++
(OOP Project)
BS(IT) 2
Submitted to:
Mam Sadaf
Submitted By:
Quratulain Naqvi (F16-1305)
Mohsin Abbas (F16-1011)
Zain
Problem Statement:
The designing of a main menu calculator.
Solution:
The designing of a main menu calculation system project will help us to:
 Create C++ classes
 Inside class concept
 Use the function of Math header file
 Develop and display the main menu and its submenus
Scope:
In most countries, students use calculators for schoolwork. There was some initial
resistance to the idea out of fear that basic arithmetic skills would suffer. There remains
disagreement about the importance of the ability to perform calculations "in the head",with
some curricula restricting calculator use until a certain level of proficiency has been obtained,
while others concentrate more on teaching estimation techniques and problem
solving.Research suggests that inadequate guidance in the use of calculating tools can restrict
the kind of mathematical thinking that students engage in. Others have argued that calculator
use can even cause core mathematical skills to atrophy, or that such use can prevent
understanding of advanced algebraic concepts.
Features:
Scientific Calculator is aimed to provide following features at its initial stage and many
more in future versions:
 Arithmetic Operations
 Trigonometric Functions
 Logarithmic Functions
 Power Functions
System module:
2.1 LIST OF MODULES:
 Arithmetic Operations
 Trigonometric Functions
 Logarithmic Functions
 Power Functions
2.2 MODULE DESCRIPTION:
2.2.1 ARITHMETIC OPERATIONS:
This function helps to perform standard calculations like:
 Addition
 Subtraction
 Multiplication
 Division
2.2.2 TRIGONOMETRIC FUNCTIONS:
This function is used to perform following calculations of:
 Sin Function
 Cos Function
 Tan Function
2.2.3 LOGARITHMIC FUNCTIONS:
This function is used to display the following functions:
 Natural Log
 Log with base 10
2.2.4 POWER FUNCTIONS:
This function is used to find:
 Power
 Square root
2.2.5 MAIN MODULES:
 Main menu
 Switch statement for submenus
2.3 CLASS DESCRIPTION:
2.3.1 CLASS NOTATIONS:
Calculator
char letter1;
char letter2;
char letter3;
char letter4;
int a,b;
double a1,b1;
int result;
double result1;
int arthimetic()
int trigonometric()
int logarithm()
int power()
2.3.1.1 CLASS NAME:
Calculator.
2.3.1.2 DATA MEMBER:
Char letter1,…,4: It is used in switch statement.
Int a,b,a1,b1 : It is used to store the input and output values.
Int result : It is used to store result in integer forms.
Double result : It is used to store result in double forms.
2.3.1.3 MEMBER FUNCTION:
int arthimetic(): It is used for doing standard calculations.
int trigonometric(): It is used for doing trigonometric calculations.
int logarithm(): It is used for doing calculations based on log and log 10.
int power(): It is used for taking power and square root of numbers.
Coding:
#include<conio.h>
#include<cmath>
using namespace std;
class calculator{
private:
char letter1;
char letter2;
char letter3;
char letter4;
int a,b;
double a1,b1;
int result;
double result1;
public:
int arthimetic(){
cout<<"nn";
cout<<"t1 : Addition n";
cout<<"t2 : Subtraction n";
cout<<"t3 : Multipilication n";
cout<<"t4 : Division nn";
letter1 = getche();
switch(letter1)
{
case '1':
{
cout<<"nnEnter first number...";
cin>>a;
cout<<"Enter another number...";
cin>>b;
result=a+b;
cout<<"nnResult = "<<result<<endl;
system("pause");
break;
}
case '2':
{
cout<<"nnEnter first number...";
cin>>a;
cout<<"Enter another number...";
cin>>b;
result=a-b;
cout<<"nnResult = "<<result<<endl;
system("pause");
break;
}
case '3':
{
cout<<"nnEnter first number...";
cin>>a;
cout<<"Enter another number...";
cin>>b;
result=a*b;
cout<<"nnResult = "<<result<<endl;
system("pause");
break;
}
case '4':
{
cout<<"nnEnter first number...";
cin>>a;
cout<<"Enter another number...";
cin>>b;
if(a!=0)
{
result=a/b;
cout<<"nnResult = "<<result<<endl;
system("pause");
}
break;
}
}
}
int trigonometric()
{
cout<<"nn";
cout<<"t1 : Sin function n";
cout<<"t2 : Cos function n";
cout<<"t3 : Tan function n";
letter2=getche();
switch(letter2)
{
case '1':
{
cout<<"nn Enter a number...";
cin>>a1;
result1=(sin(a1));
cout<<"nnResult = "<<result1<<endl;
system("pause");
break;
}
case '2':
{
cout<<"nn Enter a number...";
cin>>a1;
result1=(cos(a1));
cout<<"nnResult = "<<result1<<endl;
system("pause");
break;
}
case '3':
{
cout<<"nn Enter a number...";
cin>>a1;
result1=(tan(a1));
cout<<"nnResult = "<<result1<<endl;
system("pause");
break;
}
}
}
int logarithm()
{
cout<<"nn";
cout<<"t1 : Natural logn";
cout<<"t2 : log with base 10 n";
letter3=getche();
switch(letter3)
{
case '1':
{
cout<<"nn Enter a number...";
cin>>a1;
result1=log(a1);
cout<<"nn Result = "<<result1<<endl;
system("pause");
break;
}
case '2':
{
cout<<"nn Enter a number...";
cin>>a1;
result1= log10(a1);
cout<<"nn Result = "<<result1<<endl;
system("pause");
break;
}
}
}
int power()
{
system("cls");
cout<<"1) Press 1 for Power n";
cout<<"2) Press 2 for Square root n";
cout<<"Enter your choice....";
letter4=getche();
switch(letter4)
{
case '1':
{
cout<<"nnEnter a number...";
cin>>a1;
cout<<"Enter power...";
cin>>b1;
result1=pow(a1,b1);
cout<<"nnResult = "<<result1<<endl;
system("pause");
break;
}
case '2':
{
cout<<"nnEnter a number...";
cin>>a;
result1=sqrt(a);
cout<<"nnResult = "<<result1<<endl;
system("pause");
break;
}
}
}
};
int main()
{
calculator c;
char press,input;
int a,b;
cout<<"nnn ***************** SCIENTIFIC CALCULATOR******************
nnn";
do
{
cout<<"t 1 : Arithmetic Operations n";
cout<<"t 2 : Trigonometric Functions n";
cout<<"t 3 : Logarithmic Functions n";
cout<<"t 4 : Power Functions n";
cout<<"t 5 : Exit... n";
press=getch();
cin>>press;
switch(press)
{
case '1':
{
c.arthimetic();
break;
}
case '2':
{
c.trigonometric();
break;
}
case '3':
{
c.logarithm();
break;
}
case '4':
{
c.power();
break;
}
}
}
while(press != '5');
return 0;
}
Output:
Screenshots:
1. MAIN MENU:
LOGARITHM SUBMENU:
Our undergraduate training of Second Semester in the Department of computer Science at
The Lahore Leads University. And our respected Mam Sadaf has exposed us to a stimulating
academic environment where learning and research go hand-in-hand. He assigned us a
Project about C++ to implement the OOP concept. We had completde this before 9 july
2017.

Oop project

  • 1.
    Scientific Calculator In C++ (OOPProject) BS(IT) 2 Submitted to: Mam Sadaf Submitted By: Quratulain Naqvi (F16-1305) Mohsin Abbas (F16-1011) Zain
  • 2.
    Problem Statement: The designingof a main menu calculator. Solution: The designing of a main menu calculation system project will help us to:  Create C++ classes  Inside class concept  Use the function of Math header file  Develop and display the main menu and its submenus Scope: In most countries, students use calculators for schoolwork. There was some initial resistance to the idea out of fear that basic arithmetic skills would suffer. There remains disagreement about the importance of the ability to perform calculations "in the head",with some curricula restricting calculator use until a certain level of proficiency has been obtained, while others concentrate more on teaching estimation techniques and problem solving.Research suggests that inadequate guidance in the use of calculating tools can restrict the kind of mathematical thinking that students engage in. Others have argued that calculator use can even cause core mathematical skills to atrophy, or that such use can prevent understanding of advanced algebraic concepts. Features: Scientific Calculator is aimed to provide following features at its initial stage and many more in future versions:  Arithmetic Operations  Trigonometric Functions  Logarithmic Functions  Power Functions
  • 3.
    System module: 2.1 LISTOF MODULES:  Arithmetic Operations  Trigonometric Functions  Logarithmic Functions  Power Functions 2.2 MODULE DESCRIPTION: 2.2.1 ARITHMETIC OPERATIONS: This function helps to perform standard calculations like:  Addition  Subtraction  Multiplication  Division 2.2.2 TRIGONOMETRIC FUNCTIONS: This function is used to perform following calculations of:  Sin Function  Cos Function  Tan Function 2.2.3 LOGARITHMIC FUNCTIONS: This function is used to display the following functions:  Natural Log  Log with base 10 2.2.4 POWER FUNCTIONS: This function is used to find:  Power  Square root 2.2.5 MAIN MODULES:  Main menu  Switch statement for submenus
  • 4.
    2.3 CLASS DESCRIPTION: 2.3.1CLASS NOTATIONS: Calculator char letter1; char letter2; char letter3; char letter4; int a,b; double a1,b1; int result; double result1; int arthimetic() int trigonometric() int logarithm() int power() 2.3.1.1 CLASS NAME: Calculator. 2.3.1.2 DATA MEMBER: Char letter1,…,4: It is used in switch statement. Int a,b,a1,b1 : It is used to store the input and output values. Int result : It is used to store result in integer forms. Double result : It is used to store result in double forms. 2.3.1.3 MEMBER FUNCTION: int arthimetic(): It is used for doing standard calculations. int trigonometric(): It is used for doing trigonometric calculations. int logarithm(): It is used for doing calculations based on log and log 10. int power(): It is used for taking power and square root of numbers.
  • 5.
    Coding: #include<conio.h> #include<cmath> using namespace std; classcalculator{ private: char letter1; char letter2; char letter3; char letter4; int a,b; double a1,b1; int result; double result1; public: int arthimetic(){ cout<<"nn"; cout<<"t1 : Addition n"; cout<<"t2 : Subtraction n"; cout<<"t3 : Multipilication n"; cout<<"t4 : Division nn"; letter1 = getche(); switch(letter1) { case '1': { cout<<"nnEnter first number..."; cin>>a; cout<<"Enter another number..."; cin>>b; result=a+b; cout<<"nnResult = "<<result<<endl; system("pause"); break; } case '2': { cout<<"nnEnter first number..."; cin>>a; cout<<"Enter another number..."; cin>>b; result=a-b; cout<<"nnResult = "<<result<<endl; system("pause");
  • 6.
    break; } case '3': { cout<<"nnEnter firstnumber..."; cin>>a; cout<<"Enter another number..."; cin>>b; result=a*b; cout<<"nnResult = "<<result<<endl; system("pause"); break; } case '4': { cout<<"nnEnter first number..."; cin>>a; cout<<"Enter another number..."; cin>>b; if(a!=0) { result=a/b; cout<<"nnResult = "<<result<<endl; system("pause"); } break; } } } int trigonometric() { cout<<"nn"; cout<<"t1 : Sin function n"; cout<<"t2 : Cos function n"; cout<<"t3 : Tan function n"; letter2=getche(); switch(letter2) { case '1': { cout<<"nn Enter a number..."; cin>>a1; result1=(sin(a1)); cout<<"nnResult = "<<result1<<endl; system("pause"); break; }
  • 7.
    case '2': { cout<<"nn Entera number..."; cin>>a1; result1=(cos(a1)); cout<<"nnResult = "<<result1<<endl; system("pause"); break; } case '3': { cout<<"nn Enter a number..."; cin>>a1; result1=(tan(a1)); cout<<"nnResult = "<<result1<<endl; system("pause"); break; } } } int logarithm() { cout<<"nn"; cout<<"t1 : Natural logn"; cout<<"t2 : log with base 10 n"; letter3=getche(); switch(letter3) { case '1': { cout<<"nn Enter a number..."; cin>>a1; result1=log(a1); cout<<"nn Result = "<<result1<<endl; system("pause"); break; } case '2': { cout<<"nn Enter a number..."; cin>>a1; result1= log10(a1); cout<<"nn Result = "<<result1<<endl; system("pause"); break; } } } int power() {
  • 8.
    system("cls"); cout<<"1) Press 1for Power n"; cout<<"2) Press 2 for Square root n"; cout<<"Enter your choice...."; letter4=getche(); switch(letter4) { case '1': { cout<<"nnEnter a number..."; cin>>a1; cout<<"Enter power..."; cin>>b1; result1=pow(a1,b1); cout<<"nnResult = "<<result1<<endl; system("pause"); break; } case '2': { cout<<"nnEnter a number..."; cin>>a; result1=sqrt(a); cout<<"nnResult = "<<result1<<endl; system("pause"); break; } } } }; int main() { calculator c; char press,input; int a,b; cout<<"nnn ***************** SCIENTIFIC CALCULATOR****************** nnn"; do { cout<<"t 1 : Arithmetic Operations n"; cout<<"t 2 : Trigonometric Functions n"; cout<<"t 3 : Logarithmic Functions n"; cout<<"t 4 : Power Functions n"; cout<<"t 5 : Exit... n"; press=getch(); cin>>press; switch(press) {
  • 9.
    case '1': { c.arthimetic(); break; } case '2': { c.trigonometric(); break; } case'3': { c.logarithm(); break; } case '4': { c.power(); break; } } } while(press != '5'); return 0; }
  • 10.
  • 11.
  • 12.
    Our undergraduate trainingof Second Semester in the Department of computer Science at The Lahore Leads University. And our respected Mam Sadaf has exposed us to a stimulating academic environment where learning and research go hand-in-hand. He assigned us a Project about C++ to implement the OOP concept. We had completde this before 9 july 2017.