Hi all! THis is the program I am supposed to write:
Modify the program so it displays a menu allowing the user to select an addition, subtraction, multiplication, or division problem. The final selection on the menu should let the user quit the program. After the user has finished the math problem, the program should display the menu again. This process is repeated until the user chooses to quit the program.
Input Validation: If the user selects an item not on the menu, display an error message and display the menu again. Additional notes to pc4:
- Do not implement the subtraction, multiplication, or division. Instead, provide a message to the effect that the module is not yet ready.
- Use a switch statement to process menu choices.
- Use a 'do while' loop, as shown below.
- Here is pseudocode of what should go in the do loop for this exercise:
- do { 1. addition
- 2. subtraction
- 3. etc
- 5. quit Which would you like?
- switch (choice)
- case 1: the whole program you already wrote
- case 2: not available etc.
- case 5: Thank you and goodbye!
- default: got to be kidding, try again! }
- while( choice != 5 ); 'do while' loops and 'switch' work great for menus. The screen capture for this assignment should demonstrate a 'Not Available' and 'Exit' choice
The problem I am having is that it won't compile and I"m not sure why. This is the code I have so far does anyone know what I'm doing wrong?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int choice; // menu choice
cout << "This program written by Katy Pedro cs102 Online." << endl;
do
{
cout << " MENU " << endl;
cout << " 1. Addition\n";
cout << " 2. Subtraction\n";
cout << " 3. Multiplication\n";
cout << " 4. Division\n";
cout << " 5. Quit the program\n";
cout << "_____________________\n";
while (choice < 1 || choice > 5)
{
cout << "Enter your selection: ";
cin >> choice;
}
if (choice !=5)
{
cout << "I'm sorry but that is not available!" << endl;
switch (choice)
{
case 1: cout << "Please make a different choice, this program is not available.\n";
break;
case 2: cout << "Please make a different choice, this program is not available.\n";
break;
case 3: cout << "Please make a different choice, this program is not available.\n";
break;
case 4: cout << "Please make a different choice, this program is not available.\n";
break;
case 5: "Thank you for making the right choice! GOODBYE for now!\n";
break;
default: cout << "Are you serious? Try Again!!!\n";
}
system("PAUSE");
return 0;
}
THanks in advance any help is greatly appreciated!!!:cheesy: