Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students explore these related Databases questions