Question
Scientific calculator c++: Hi, Here is my code for a scientific calculator but i need this: Please identify the data structures and algorithms in your
Scientific calculator c++:
Hi, Here is my code for a scientific calculator but i need this:
Please identify the data structures and algorithms in your program and how they are fundamental to the successful execution of the program. Must also include internal documentation (comments explaining the functioning of the source code) Basically a few paragraphs explaining the data structures in the code and their importance in the program.
COde:
#include
#include
{ cout << " "; cout << "\t1 : Addition "; cout << "\t2 : Subtraction "; cout << "\t3 : Multipilication "; cout << "\t4 : Division "; cin >> letter1; switch (letter1) { case '1': { cout << " Enter first number..."; cin >> a; cout << "Enter an other number..."; cin >> b; result = a + b; cout << " Result = " << result << endl; break; } case '2': { cout << " Enter first number..."; cin >> a; cout << "Enter an other number..."; cin >> b; result = a - b; cout << " Result = " << result << endl; break; }
case '3': { cout << " Enter first number..."; cin >> a; cout << "Enter an other number..."; cin >> b; result = a * b; cout << " Result = " << result << endl; break; }
case '4': { cout << " Enter first number..."; cin >> a; cout << "Enter an other number..."; cin >> b; if (a != 0) { result = a / b; cout << " Result = " << result << endl;
} break; } } // end of inner switch break; } // end of case 1 arithmatic operation
case '2': { cout << " "; cout << "\t1 : Sin function "; cout << "\t2 : Cos function "; cout << "\t3 : Tan function "; cin >> letter2; switch (letter2) { case '1': { cout << " Enter a number..."; cin >> a1; result1 = (sin(a1)); cout << " Result = " << result1 << endl; break; } case '2': { cout << " Enter a number..."; cin >> a1; result1 = (cos(a1)); cout << " Result = " << result1 << endl; break; } case '3': { cout << " Enter a number..."; cin >> a1; result1 = (tan(a1)); cout << " Result = " << result1 << endl; break; } } // inner switch break; } // inner case 2 trignomatic case '3': { cout << " "; cout << "\t1 : Natural log "; cout << "\t2 : log with base 10 "; cin >> letter3; switch (letter3) { case '1': { cout << " Enter a number..."; cin >> a1; result1 = log(a1); cout << " Result = " << result1 << endl; break; } case '2': { cout << " Enter a number..."; cin >> a1; result1 = log10(a1); cout << " Result = " << result1 << endl; break; } } // end of switch break; } // end of case 3 logrithmic case '4': { cout << "1) Press 1 for Power "; cout << "2) Press 2 for Square root "; cout << "Enter your choice...."; cin >> letter4; switch (letter4) { case '1': { cout << " Enter a number..."; cin >> a1; cout << "Enter power..."; cin >> b1; result1 = pow(a1, b1); cout << " Result = " << result1 << endl; break; } case '2': { cout << " Enter a number..."; cin >> a; result1 = sqrt(a); cout << " Result = " << result1 << endl; break; }
} // end of switch break; } // end of case power function
} // outer switch } while (letter != '5'); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started