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

Will rate highest possible for solution to this problem! Must run without errors

ID: 670694 • Letter: W

Question

Will rate highest possible for solution to this problem! Must run without errors =D

Write a C++ program that uses selection and repitition constructs as needed to solve the following problem.

Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu.

The menu options are:

               Help                      AddDoubles                                      MulIntegers                                      Quit             

Once the menu item is selected and validated, the program will proceed with processing that selection as explained below.

If the user selects h or H, the program displays a help screen and tells the user how the program operates and what is needed from the user and how the program is terminated.

Once the user viewed the help screen, striking any key will follow with the display of the menu again.

If the user selects a, or A, the user is prompted for two valid numbers of type double. This option will then use the two numbers, adds them and displays the result in the format shown below. For example, if the two double numbers are 16.75 and 30.18, then the result is displayed as shown below.

The sum of    16.75 + 30.18 = 46.93

There must be two digits after the decimal point.

Once the user viewed the result, striking any key will clear the screen, followed by display of the menu again.

If the user selects m or M, the program prompts the user for two valid integer numbers. The program will then compute the product and displays the operands and the product. If the two integer numbers are 16 and -48, then the result is displayed as shown below.

The product of    16 * -48 = -768

Once the user viewed the result, striking any key will clear the screen, followed by display of the menu again.

If the user selects q or Q, the program clears the screen, displays the following message and the program will then terminate.

The program terminated per the user request…

Any other menu item is flagged as an error and the user is warned to make another selection from the menu, and the menu is displayed again. The wrong input should not terminate the program.

Once the program begins execution, it will not terminate until the user inputs q orQ.

For data of type double, run your program with the following sets of data:

32.46, 76.28

-165.24, 42.42

21.54, -45.25

-24.0, -56.0

For data of type integer, run your program with the following sets of data:

5, 9

-52, 48

475, -266

-47, -35

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int num, count;
char cont;
bool notprime;

char option;
do {

   cout << "Menu Options: h/H - Help a/A - AddDoubles m/M - MulIntegers q/Q- Quit" <<endl;
   cout << "Enter Your Option: "<<endl;
   cin>> option;

   if(option == 'h' || option == 'H') {

       cout << "h/H - Help Displays help for the command execution" <<endl;
       cout << "a/A - AddDoubles The user is prompted for two valid numbers of type double. And it adds the two number" <<endl;
       cout << "m/M - MulIntegers The user is prompted for two valid integer numbers. This will then compute the product and displays the operands and the product"<< endl;
   } else if(option == 'a' || option == 'A') {
          cout << "Enter two valid numbers of type double "<<endl;
          double num1, num2;
          cin >> num1;
          cin >> num2;
          double sum = num1+num2;
          cout << "The sum of "<<num1 <<" + " <<num2 << "=" <<fixed << setprecision(2) << sum <<endl;

   } else if(option == 'm' || option == 'M') {
       cout << "Enter two valid integer numbers "<<endl;
                  int num1, num2;
                  cin >> num1;
                  cin >> num2;
                  int mul = num1 * num2;
                  cout << "The product of "<<num1 <<" * " <<num2 << "=" <<mul <<endl;
   } else if(option == 'q' || option == 'Q') {
       cout << "The program terminated per the user request…"<<endl;
       break;
   } else {
       cout <<"Error: Invalid option. Please select proper option"<<endl;
   }

} while(option != 'q'|| option != 'Q');
}

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