Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

50. Write a C++ program which allows the user to perform simple tasks on a calcu

ID: 3850673 • Letter: 5

Question

50. Write a C++ program which allows the user to perform simple tasks on a calculator. A series of functions allows the user to select an operation to perform and then enter operands. The first function displays a menu, giving the user the choice of typing in any one of the following: +, -, *, /, or % representing the usual arithmetic operators A representing the average of two numbers X representing the maximum of two numbers M representing the minimum of two numbers S representing the square of a number Q indicating the user wants to quit the program The program reads the user's response into a variable of type char. Using a switch statements, the program determines what function to call to process the user's request. For example, if the user enters +, another function asks for two integers. Then it finds the sum of the two integers. If the user enters X, a function asks for two integers and finds the larger of the two. If the user enters S, a function asks for one value and finds the square of that value. If the user enters Q, the program stops. For each calculation performed, the program (i.e., the function) prints the user's original input and the result.

Explanation / Answer

break; case '%' : cout<<"Enter a number : "; cin>>a; res=sqrt(a); cout<<"square root = "<<res; break; case 'Q' : exit(0); break; default : cout<<"Wrong Choice..!!"; break; } cout<<" ------------------------------------ "; }while(choice!=Q && choice!=getchar()); getch();

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote