Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using namespace std; void main() { char letter; char letter1; char letter2; char letter3; char letter4; int a, b; double a1, b1; int result; double result1; cout << " ***************** SCIENTIFIC CALCULATOR ****************** "; do { cout << "\t 1 : Arithmetic Operations "; cout << "\t 2 : Trigonometric Functions "; cout << "\t 3 : Logarithmic Functions "; cout << "\t 4 : Power Functions "; cout << "\t 5 : Exit... "; cin >> letter; switch (letter) { case '1':

{ 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago