Help with a Menu Driven Program

This is my first time posting, so sorry if it doesn't sound very well written.

I need help finishing my menu driven program. The question states:
Jason sells coffee in 3 sizes. Small 9oz, medium 12oz, large 15oz. The cost of small is $1.75, medium is $1.90, and large is $2.00. Write a menu-driven program that will make the coffee shop operational. The program should be able to allow the user to buy coffee in any size and amount, at any time show the total number of cups of each size sold, at any time show the total amount of coffee sold (in ounces), at any time show the total money made, and a tutorial of how to use the program.

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
#include<iostream>

using namespace std;


int main()
{
	int size;
	int amount;
	int amountSmall;
	int amountMedium;
	int amountLarge;
	double SMALL = 1.75;
	double MEDIUM = 1.90;
	double LARGE = 2.0;
	double customerTotal;
	int SMALLOZ = 9;
	int MEDIUMOZ = 12;
	int LARGEOZ = 15;
	int totalCupsSold;
	double amountSold = 0.0;
	double moneyEarned = 0.0;
	int choice;

	
		cin >> choice;
		cout << endl;

		cout << "Please make a selection: \n"
			"1. Sell a coffee \n"
			"2. Total number of cups sold today \n"
			"3. Total amount of coffee sold today \n"
			"4. Total money made today \n"
			"5. Tutorial \n";
		cin >> choice;

		if (choice = 1)
		{
			cout << "Enter the amount of small coffees: ";
			cin >> amountSmall = amountSmall + SMALL;
			cout << "Enter the amount of medium coffees: ";
			cin >> amountMedium = amountMedium + MEDIUM;
			cout << "Enter the amount of large coffees: ";
			cin >> amountLarge = amountLarge + LARGE;
			cin >> customerTotal = amountSmall + amountMedium + amountLarge;
		}

		else if (choice = 2)
		{
			cin >> totalCupsSold = SMALL + MEDIUM + LARGE;
			cout << "The total number of cups sold today are: " << totalCupsSold;
		}

		else if (choice = 3)
		{
			cin >> amountSold = (SMALL * SMALLOZ) + (MEDIUM * MEDIUMOZ) + (LARGE * LARGE OZ);
			cout << "The total amount of coffee sold is " << amountSold << "oz.";
		}

		else if (choice = 4)
		{
			cin >> moneyEarned = customerTotal;
			cout << "Total amount earned today is: $";
		}

		else if (choice = 5)
		{
			cout << "Tutorial: \n Select an option from the start menu. Enter the numerical value into the computer. Follow the on screen directions and exit when done."
		}

		else 
		{
			cout << "Error. That option is not avalible.";
			return 0;
		}

	system("pause");
	return 0;
}
Hey And welcome to the forum. First I Wanna say Im very impressed that you used code tags in your very first post, I dont think Ive seen that for over a month.

Could you give us more information, as in. What is wrong exactly, what is missing, is it not compiling, and stuff like that. Maybe input you tried and you got the wrong output, what output did you expect in that case? etc
Here's one example of a menu driven system:

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include <limits>

using std::cin;
using std::cout;
using std::endl;

void mainMenu(int &choice)
{
    cout << "Main Menu" << endl;
    cout << "\t1) Choice 1" << endl;
    cout << "\t2) Choice 2" << endl;
    cout << "\t3) Quit" << endl;
    if (!(cin >> choice) || choice < 1 || choice > 3)
    {
        cout << "Invalid entry." << endl;
        cin.clear();
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        mainMenu(choice);
    }
}

void menu1(int &choice)
{
    cout << "Submenu 1 of Main Menu" << endl;
    cout << "\t1) Choice 1" << endl;
    cout << "\t2) Choice 2" << endl;
    cout << "\t3) Choice 3" << endl;
    cout << "\t4) Choice 4" << endl;
    if (!(cin >> choice) || choice < 1 || choice > 4)
    {
        cout << "Invalid entry." << endl;
        cin.clear();
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        menu1(choice);
    }
}

void menu11(int &choice)
{
    cout << "Submenu 1 of Submenu 1 of Main Menu" << endl;
    cout << "\t1) Choice 1" << endl;
    cout << "\t2) Choice 2" << endl;
    if (!(cin >> choice) || choice < 1 || choice > 2)
    {
        cout << "Invalid entry." << endl;
        cin.clear();
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        menu11(choice);
    }
}

void menu111(int &choice)
{
    cout << "Submenu 1 of Submenu 1 of Submenu 1 of Main Menu" << endl;
    cout << "Instead of having all those switches in main, I could put them inside these menu functions." << endl;
}

void menu112(int &choice)
{
    cout << "Submenu 2 of Submenu 1 of Submenu 1 of Main Menu" << endl;
    cout << "I'm afraid there might be a limit to how many nested function calls you can have with all the recursion though." << endl;
}

void menu12(int &choice)
{
    cout << "Submenu 2 of Submenu 1 of Main Menu" << endl;
    cout << "All these submenus are giving me a headache." << endl;
}

void menu13(int &choice)
{
    cout << "Submenu 3 of Submenu 1 of Main Menu" << endl;
    cout << "The pattern is already obvious, right?" << endl;
}

void menu14(int &choice)
{
    cout << "Submenu 4 of Submenu 1 of Main Menu" << endl;
    cout << "The first digit after \"menu\" is the choice from the first menu, the second is the choice from the second menu, etc." << endl;
}

void menu2(int &choice)
{
    cout << "Submenu 2 of Main Menu" << endl;
    cout << "\t1) Choice 1" << endl;
    cout << "\t2) Choice 2" << endl;
    cout << "\t3) Choice 3" << endl;
    if (!(cin >> choice) || choice < 1 || choice > 3)
    {
        cout << "Invalid entry." << endl;
        cin.clear();
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        menu2(choice);
    }
}

void menu21(int &choice)
{
    cout << "Submenu 1 of Submenu 2 of Main Menu" << endl;
    cout << "The if statement after the choices are to ensure that the input is valid." << endl;
}

void menu22(int &choice)
{
    cout << "Submenu 2 of Submenu 2 of Main Menu" << endl;
    cout << "If the input is invalid, then output a statement saying so, and fix the input stream." << endl;
}

void menu23(int &choice)
{
    cout << "Submenu 3 of Submenu 2 of Main Menu" << endl;
    cout << "Then recursively call the menu again, until the input is valid." << endl;
}

int main()
{
    int choice;
    do
    {
        mainMenu(choice);
        switch(choice)
        {
            case 1:
            {
                menu1(choice);
                switch(choice)
                {
                    case 1:
                    {
                        menu11(choice);
                        switch(choice)
                        {
                            case 1: menu111(choice); break;
                            case 2: menu112(choice); break;
                        }
                        break;
                    }
                    case 2: menu12(choice); break;
                    case 3: menu13(choice); break;
                    case 4: menu14(choice); break;
                }
                break;
                    }
            case 2:
            {
                menu2(choice);
                switch(choice)
                {
                    case 1: menu21(choice); break;
                    case 2: menu22(choice); break;
                    case 3: menu23(choice); break;
                }
                break;
            }
            case 3: choice = 0; break;
        }
    } while (choice != 0);
}

I won't claim it's any good, but it works.
Note: Each menu item can be broken down into separate 'function' for better structure and readability. I didn't use functions because I wasn't sure whether you are familiar with 'functions' yet... Anyway, Here is the code snippet of my version to your question. Happy coding...

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#include <iostream>
#include <iomanip>

using namespace std;

int main ()
{
	int cupSmall (0),	sizeSmall (0),		choice (0), 
	    cupMedium (0),	sizeMedium (0),		quantity (0),
	    cupLarge (0),	sizeLarge (0);

	double priceSmall (0),
               priceMedium (0),
               priceLarge (0);

	while (true)
	{	
		system("cls"); // Not cross-platform 

		// Display Menu
		cout << "\n\n\n\n\n\t\t| Welcome to Jason's Cafe |\n\n"
	             << "\n\t1. Sell Coffee."
		     << "\n\t2. Total number of coffee sold [in cups]"
	       	     << "\n\t3. Total amount of coffee sold [in ounces]"
		     << "\n\t4. Total Sales."
		     << "\n\t5. Tutorial [How to use this program]"
		     << "\n\t6. Exit"
			 << "\n\n\n\t- Enter your choice [1 - 6]: ";

		cin >> choice;

		// Input Validation
		while ( cin.bad() || choice < 1 || choice > 6 )
		{
			cout << "\t- Invalid Option. Enter your choice again: ";
			
			cin.clear();
			cin.ignore(1000, '\n');

			cin >> choice;
		} // End of Input Validation

		
		// 1. Sell Coffee
		if (choice == 1)
		{
			system("cls");
			do
			{
				cout << "\n\n\n\n\n     | Size || Quantity || Price |"
				     << "\n\n   1. Small     (9oz)      $1.75"
				     << "\n   2. Medium    (12oz)     $1.90"
				     << "\n   3. Large     (15oz)     $2.00"
				     << "\n\n   4. Go to Main Menu"
				     << "\n   5. Exit Program"
				     << "\n\n\n\n   - Select Your option [1 - 5]: ";

				cin >> choice;

				// Input Validation
				while ( cin.fail() || choice < 1 || choice > 5 )
				{
					cout << "   - Invalid Option. Enter your choice again: ";
			
					cin.clear();
					cin.ignore(1000, '\n');

					cin >> choice;
				} // End of Input Validation

				if ( choice == 1 || choice == 2 || choice == 3 )
				{
					cout << "\n\n   - Enter quantity: ";
					cin >> quantity;
			
					// Input Validation
					while ( cin.fail() || quantity <= 0 )
					{
						cout << "   - Invalid Quantity. Enter your quantity again: ";
			
						cin.clear();
						cin.ignore(1000, '\n');

						cin >> quantity;
					} // End of Input Validation
				}


				// 1. Small Coffee
				if ( choice == 1 )
				{
					cupSmall += quantity; 
					sizeSmall += 9 * quantity; 
					priceSmall += 1.70 * quantity;

					cout << "\n\n\n\n\n\t------------------------------------------"
					     << "\n\t     " << quantity << " small coffee(s) @ 1.70/cup"
					     << "\n\t              Thank you..."
					     << "\n\t------------------------------------------\n\n\n\n\n\t";

					system("pause");
					break;
				} // End of 1. Small


				// 2. Medium Coffee
				else if ( choice == 2 )
				{
					cupMedium += quantity; 
					sizeMedium += 12 * quantity; 
					priceMedium += 1.90 * quantity;

					cout << "\n\n\n\n\n\t------------------------------------------"
					     << "\n\t     " << quantity << " medium coffee(s) @ 1.90/cup"
					     << "\n\t              Thank you..."
				             << "\n\t------------------------------------------\n\n\n\n\n\t";

					system("pause"); // Not cross-platform
					break;
				} // End of 2. Medium Coffee


				// 3. Large Coffee
				else if ( choice == 3 )
				{
					cupLarge += quantity; 
					sizeLarge += 15 * quantity; 
					priceLarge += 2.00 * quantity;

					cout << "\n\n\n\n\n\t------------------------------------------"
					     << "\n\t     " << quantity << " large coffee(s) @ 2.00/cup"
					     << "\n\t              Thank you..."
					     << "\n\t------------------------------------------\n\n\n\n\n\t";

					system("pause");
					break;
				} // End of 3. Large Coffee


				// Go to main menu
				else if ( choice == 4 ) break;

				// Exit program
				else return 0;
			} while ( choice );
		} // End of 1. Sell Coffee



		// 2. Total number of coffee sold [in cups]
		else if ( choice == 2 )
		{
			system("cls");

			cout << "\n\n\n\n\n\t- Total number of coffee sold [in cups] : " 
			     << cupSmall + cupMedium + cupLarge << " Cups.\n\n\t"
			     << cupSmall << "\tSmall cup(s)\n\t"
		   	     << cupMedium << "\tMedium cup(s)\n\t"
			     << cupLarge << "\tLarge cup(s)\n\n\n\t";

			system("pause");
		} // End of 2. Total number of coffee sold [in cups]



		// 3. Total amount of coffee sold [in ounces]
		else if ( choice == 3 )
		{
			system("cls");

			cout << "\n\n\n\n\n\t- Total amount of coffee sold [in ounces] : " 
			     << sizeSmall + sizeMedium + sizeLarge << " Ounces.\n\n\t"
			     << cupSmall << "\t9oz Coffee\n\t"
			     << cupMedium << "\t12oz Coffee\n\t"
			     << cupLarge << "\t15oz Coffee\n\n\n\t";

			system("pause");
		} // End of 3. Total amount of coffee sold [in ounces] 	



		// 4. Total Sales
		else if ( choice == 4 )
		{
			system("cls");

			cout << "\n\n\n\n\n\t- Total Sales [in amount] : $" << fixed << setprecision(2)
			     << priceSmall + priceMedium + priceLarge << "\n\n\t"
			     << cupSmall << "\tSmall Coffee    [1.70/cup]\n\t"
			     << cupMedium << "\tMedium Coffee   [1.90/cup]\n\t"
			     << cupLarge << "\tLarge Coffee    [2.00/cup]\n\n\n\t";

			system("pause");
		} // End of 4. Total Sales



		// 5. Tutorial [How to use this program]
		else if ( choice == 5 )
		{
			system("cls");

			cout << "\n\n\n\t\t| Tutorial |"
			     << "\n\n\tYour Tutorial information goes here...\n\n\n\t";

			system("pause");
		} // End of 5. Tutorial [How to use this program]


		// 6. Exit Program
		else return 0;;
	} //while ( choice ); // Go back to main menu, until user enters 6 to exit the program
} // End of main () 
  // End of Program. 

@ OP

Check your IF statements, you are using a single = instead of == so your IF statements will fail. For example, line 37 you have:

if (choice = 1)

which should be

if (choice == 1)

Also check your syntax for cin, you are performing calculations on cin - this cant be done. Check these links which should help: http://www.cplusplus.com/doc/tutorial/basic_io/ and http://www.cplusplus.com/doc/tutorial/control/




Thank you everyone for replying! I really appreciate it.
My teacher has went over functions, but I'm not sure how to do them correctly, so I was just going to use if else statements.
digital D: I tried to run the program you posted, and it says there is an error on line 211. It doesn't give me an error code, it just says "expected expression" (Xcode). Is it actually correct?
yeah, i see an extra semi-colon(;) there on line 211. That is not really an error, it just an empty statement. Remove that and it should be fine. I tested those codes on Visual Basics, as well as on Xcode. No problems.

Happy coding...
Thanks!
Topic archived. No new replies allowed.