Question: C++- Please solve TODO sections and match sample output. Demonstrate event-controlled loop using boolean flag to present a menu. Use nested decision structure to process

C++- Please solve TODO sections and match sample output.

Demonstrate event-controlled loop using boolean flag to

present a menu. Use nested decision structure to process

each choice including invalid response.

*/

#include

#include

using namespace std;

const char QUIT = '0'; // constants for menu options

const char INPUT = '1';

const char PROCESS = '2';

const char OUTPUT = '3';

int main()

{

char userSelection; // input for menu choice

bool done; // flag for loop control

// TODO: Initialize the loop control variable (done).

// Think about what an appropriate value for 'done' would be.

// Are we done at the beginning of the program?

// TODO: Begin loop here. Test the loop control variable

// Do NOT test the userSelection variable

// display the menu

cout << endl

<< setw(25) << " Program Menu " << endl

<< setw(25) << "---------------------" << endl

<< setw(25) << "1 ...... Input " << endl

<< setw(25) << "2 ...... Process " << endl

<< setw(25) << "3 ...... Output " << endl

<< setw(25) << "0 ...... Quit Program" << endl

<< setw(25) << "---------------------" << endl;

// get user response

cout << setw(20) << "Enter option: ";

cin >> userSelection;

// TODO: Process menu responses using If-Then-Else-If.

// For each option, print appropriate message as shown

// in sample output below, including invalid choice.

// Also, be sure to use the provided constants when

// you are testing values.

// TODO: End loop here.

cout << " End Program - ";

}

/* Sample Program Interaction and Output

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: 1

Do INPUT stuff

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: 2

Do PROCESS stuff

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: 3

Do OUTPUT stuff

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: 4

Invalid choice, please try again.

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: q

Invalid choice, please try again.

Program Menu

---------------------

1 ...... Input

2 ...... Process

3 ...... Output

0 ...... Quit Program

---------------------

Enter option: 0

End Program - Press any key to continue . . .

*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!