Scientific Calculator Project Using C++
Scientific Calculator Project Using C++
Scientific Calculator Project Using C++
<<
<<
<<
<<
<<
"\t
"\t
"\t
"\t
"\t
switch (op) {
case '+':
operand1 = operand1 + operand2;
cout << str << "=" << operand1 << endl;
break;
case '-':
operand1 = operand1 - operand2;
cout << str << "=" << operand1 << endl;
break;
case '*':
operand1 = operand1*operand2;
cout << str << "=" << operand1 << endl;
break;
case '/':
operand1 = operand1 / operand2;
cout << str << "=" << operand1 << endl;
break;
case '=':
cout << str << "=" << operand1 << endl;
break;
case 'c':
case 'C':
str = "";//reset the string for next expression
isFirst = true;//reset the flag for next expression
break;
case 'Q':
case 'q':
return;
default:
cout << "Invalid Operator" << endl;
}
} while (true);
char option;
double operand;
do {
cout << "Trigonometric Operations" << endl;
cout << "\t a) sine function" << endl;
cout << "\t b) cosine function" << endl;
cout << "\t c) tangent function" << endl;
cout << "\t d) sine inverse function" << endl;
cout << "\t e) cosine inverse function" << endl;
cout << "\t f) tangent inverse function" << endl;
cout << "\t g) sine hyperbolic function" << endl;
cout << "\t h) cosine hyperbolic function" << endl;
cout << "\t i) tangent hyperbolic function" << endl;
cout << "\t j) sine inverse hyperbolic function" << endl;
cout << "\t k) cosine inverse hyperbolic funtion" << endl;
cout << "\t l) tangent inverse hyperbolic funtion" << endl;
cout << "\t m) Exit" << endl;
cout << "Enter your choice\t:";
option=_getche();
cout << endl;
switch (option)
{
case 'a':
case 'A':
cout << "\nEnter the Angle in Radian: \t";
while (!(cin >> operand)) {
cout << "\nRe-Enter the Angle in Radian: \t";
cin.clear();
cin.ignore(1000, '\n');
endl;
}
cout << "sin(" << operand << ")=" << sin(operand) <<
break;
case 'b':
case 'B':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "cos(" << operand << ")=" << cos(operand) <<
endl;
endl;
break;
case 'c':
case 'C':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "tan(" << operand << ")=" << tan(operand) <<
break;
case 'd':
case 'D':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "asin(" << operand << ")=" << asin(operand) <<
endl;
break;
case 'e':
case 'E':
<< endl;
<< endl;
endl;
break;
case 'g':
case 'G':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "sinh(" << operand << ")=" << sinh(operand) <<
break;
case 'h':
case 'H':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "cosh(" << operand << ")=" << cosh(operand)
<< endl;
<< endl;
break;
case 'i':
case 'I':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "tanh(" << operand << ")=" << tanh(operand)
break;
case 'j':
case 'J':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "sineInverseHyperbolic(" << operand << ")=" <<
log(operand + sqrt(pow(operand, 2) + 1)) << endl;
break;
case 'k':
case 'K':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "cosineInverseHyperbolic(" << operand << ")="
<< log(operand + sqrt(pow(operand, 2) - 1)) << endl;
break;
case 'l':
case 'L':
cout << "Enter the Angle in Radian: \t";
cin >> operand;
cout << "tangentInverseHyperbolic(" << operand << ")="
<< (log(1 + operand) - log(1 - operand)) / 2 << endl;
break;
case 'm':
case 'M':
return;
default:
}
} while (true);
endl;
break;
case '2':
cout << "Enter the operand:\t";
cin >> operand;
cout << "cube(" << operand << ")=" << operand * operand *
break;
case '3':
cout << "Enter the operand:\t";
cin >> operand;
cout << "Enter the power:\t";
cin >> power;
cout << operand << "^" << power << "=" << pow(operand,
break;
case '4':
cout << "Enter the operand:\t";
cin >> operand;
cout << "squareroot(" << operand << ")=" << sqrt(operand) <<
endl;
break;
case '5':
cout << "Enter the operand:\t";
cin >> operand;
cout << "cuberoot(" << operand << ")=" << pow(operand, (1.0 /
break;
case '6':
cout << "Enter the operand:\t";
cin >> operand;
cout << "Enter the root value:\t";
cin >> root;
cout << root << "root of " << operand << "=" << pow(operand,
break;
case '7':
return;
default:
cout << "Invalid Choice" << endl;
}
} while (true);
}
else {
}
};
void main() {
char choice;
do {
cout << "\n------------------Scientific Calculator---------------------" << endl;
cout << "\t 1) Arithmetic Operations" << endl;
cout << "\t 2) Trigonometric Operations" << endl;
cout << "\t 3) Logorithemic Operations" << endl;
cout << "\t 4) Power Operations" << endl;
cout << "\t 5) Factorial Operation" << endl;
cout << "\t 6) Exit" << endl;
cout << "Enter your choice:\t";
choice = _getche();
cout << endl;
ScienntificCalculator sc;
switch (choice) {
case '1':
//cout<<"Airthemetic operations"<<endl;
sc.arithmeticOperations();
break;
case '2':
//cout<<"Trigonometric operations"<<endl;
sc.trigonometricOperations();
break;
case '3':
//cout << "Logorithemic operations" << endl;
sc.logarithmicOperations();
break;
case '4':
//cout << "Power operations" << endl;
sc.powerOperations();
break;
case '5':
//cout << "Factorial operations" << endl;
sc.factorialOperation();
break;
case '6':
cout << "Thank you for using Scientific Calculator!!!" << endl;
_getch();
return;
default:
cout << "Invalid Choice" << endl;
}
_getch();
} while (true);
}