currently taking an online course nd Im havin trble with this asnmnt,I would appreciate hlp nd wil post my bad code 4guidance

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 Demonstrate event-controlled loop using boolean flag to
 present a menu. Use nested decision structure to process
 each choice including invalid response.
*/

#include<iostream>
#include<iomanip>
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 << "\nEnd 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 */
Last edited on
What have YOU done?

Because it looks like a "complete this code by filling in all the TODOs" assignment, yet you haven't even attempted to complete any of the TODOs.

Here's a freebie.
1
2
3
4
// 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?
done = false;
oops, meant to post what I had before based on what I found but I'm afraid its Horribly wrong. please help.
#include<iostream>
#include<iomanip>
using namespace std;

const char QUIT = '0'; // constants for menu options
const char INPUT = '1';
const char PROCESS = '2';
const char OUTPUT = '3';
const char FOUR = '4';
const char q = 'q';

void DisplayMenu(char & ch);
void input();
void process();
void output();

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?

done = false;

// TODO: Begin loop here. Test the loop control variable
// Do NOT test the userSelection variable


while (!done)
{

DisplayMenu(userSelection);


if (userSelection == 1)
{
Input();
}
else if (userSelection == 2)
{
process();
}
else if (userSelection == 3)
{
output();
}
else if (userSelection == 0)
{
done = true;
}
else
{
cout << "\nInvalid choice, please try again.\n";
}

// display the menu]

void DisplayMenu(char& ch)
{
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.

{
if (userSelection == FOUR)
{
cout << "Invalid choice, please try again." << endl;
}

else if (userSelection == q)
{
cout << "Invalid choice, please try again." << endl;
}
else (userSelection == QUIT)
{
done = true;
}


}
// TODO: End loop here.


cout << "\nEnd Program - ";
}
Topic archived. No new replies allowed.