Validating Menu Items using a while loop

Hello, I was wondering if anyone would be able to help me with this nested loop issue I'm having.

I'm currently creating a deli simulator which allows the user to select a base item and then customize said item. However, I'm having trouble with validating the choices. For instance, below I posted a segment (which is nested under an if else statement within a while loop) of my code where the breakfast burrito has been chosen so it displays the burrito creator menu. And it validates by saying if it's less than 1 or greater than 4 go back to the menu using the while loop... but now, I can't do any selections between 1 and 4. Every entry I put loops me back to the creator screen rather than moving onto "select your toppings".

I've been trying to solve this for nearly 2 hours and this has come as a last result as I'm frustrated and lost as to what to do. Does anyone know how to make the program proceed within the nested while loop?

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
//Breakfast Burrito
int bBurrito = 2.99;

f (choiceB[0] == '1')
{
while (1)
{
system("cls");
cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
cout << ">>                        Breakfast Burrito Creator                           >>" << endl;
cout << ">>                                                                            >>" << endl;
cout << ">>                       Please Enter Your Selection                          >>" << endl;
cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;

//Breakfast Burrito Styles
char burritoChoice[2];

cout << "1. Scrambled Eggs and Cheese Burrito \n"
     << "2. Scrambled Eggs, Cheese and Bacon Burrito \n"
     << "3. Scrambled Eggs, Cheese and Sausage Burrito \n"
     << "4. Scrambled Eggs, Cheese and Chicken Burrito \n\n"
     << "Enter your choice: ";
cin >> burritoChoice;

//scrmbldEgg+Cheese
if (burritoChoice[0] == '1')
{
system("cls");
cout << "                                     Select your toppings" << endl;
}
//scrmbldEgg+Bacon
else if (burritoChoice[0] == '2')
{
system("cls");
cout << "                                     Select your toppings" << endl;
}

//scrmbldEgg+Sausage
	else if (burritoChoice[0] == '3')
	{
		system("cls");
		cout << "                                     Select your toppings" << endl;
	}


//scrmbldEgg+Chicken
		else if (burritoChoice[0] == '4')
		{
								system("cls");
			cout << "                                     Select your toppings" << endl;
		}

//Burrito Selection Validation
			else if (burritoChoice[0] > '4' || burritoChoice[0] < '1')
			{
				system("cls");
				cout << "Invalid entry, please enter a number 1-4 corresponding to the menu choice." << endl << endl;
				cout << "Please try again" << endl;
				system("pause");
				system("cls");
			} //ends validation else if
} //ends if burrito 1 statement 
Put you entire code.
It's hard to diagnose the code without running it.
Thanks for the reply, here's the full code (apologies for formatting):

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
//This is Brandon Abraham's Deli Ordering System
//This code was created for CIS 114-450 for Jason Silverstein
//This program allows users to order traditional deli items through an intuitive deli ordering system


//Deli Ordering System

#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <string>
#include <cstdlib>

using namespace std;


int main()
{
	//Welcome Screen
	cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
	cout << ">>                                Welcome To                                 >>" << endl;
	cout << ">>                              Brandon's Deli                               >>" << endl;
	cout << ">>                                                                           >>" << endl;
	cout << ">>                          Press any key to start                           >>" << endl;
	cout << ">>                                                                           >>" << endl;
	cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;


	system("pause");
	system("cls");

	//Menu Selection
	cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
	cout << ">>                                  Menu                                      >>" << endl;
	cout << ">>                                                                            >>" << endl;
	cout << ">>                       Please Enter Your Selection                          >>" << endl;
	cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;

	//Menu Items
		
		while (1)
		{
			char choice[2];

			cout << "1. Breakfast \n"
				 << "2. Lunch \n"
				 << "3. Dinner \n\n"
				 << "Enter your choice: ";
			cin >> choice;
			

			//Breakfast Menu
			if (choice[0] == '1')
			{
				system("cls");
				cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
				cout << ">>                             Breakfast Menu                                 >>" << endl;
				cout << ">>                                                                            >>" << endl;
				cout << ">>                       Please Enter Your Selection                          >>" << endl;
				cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;

				
					char choiceB[2];

					cout << "1. Breakfast Burrito \n"
						 << "2. Breakfast Hoagie \n"
						 << "3. Breakfast Sandwich \n"
						 << "4. Breakfast Sizzli \n"
						 << "Enter your choice: ";
				cin >> choiceB;

				//Breakfast Burrito
				int bBurrito = 2.99;

				if (choiceB[0] == '1')
				{
					while (1)
					
						{
							system("cls");
							cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
							cout << ">>                        Breakfast Burrito Creator                           >>" << endl;
							cout << ">>                                                                            >>" << endl;
							cout << ">>                       Please Enter Your Selection                          >>" << endl;
							cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;


							//Breakfast Burrito Styles
							char burritoChoice[2];

							cout << "1. Scrambled Eggs and Cheese Burrito \n"
								<< "2. Scrambled Eggs, Cheese and Bacon Burrito \n"
								<< "3. Scrambled Eggs, Cheese and Sausage Burrito \n"
								<< "4. Scrambled Eggs, Cheese and Chicken Burrito \n\n"
								<< "Enter your choice: ";
							cin >> burritoChoice;

							//scrmbldEgg+Cheese
							if (burritoChoice[0] == '1')
							{
								system("cls");
								cout << "                                     Select your toppings" << endl;
							}

							//scrmbldEgg+Bacon
							else if (burritoChoice[0] == '2')
							{
								system("cls");
								cout << "                                     Select your toppings" << endl;
							}

							//scrmbldEgg+Sausage
							else if (burritoChoice[0] == '3')
							{
								system("cls");
								cout << "                                     Select your toppings" << endl;
							}


							//scrmbldEgg+Chicken
							else if (burritoChoice[0] == '4')
							{
								system("cls");
								cout << "                                     Select your toppings" << endl;
							}

							//Burrito Selection Validation
							else if (burritoChoice[0] > '4' || burritoChoice[0] < '1')
							{
								system("cls");
								cout << "Invalid entry, please enter a number 1-4 corresponding to the menu choice." << endl << endl;
								cout << "Please try again" << endl;
								system("pause");
								system("cls");
							} //ends validation else if
						}
				} //ends if burrito 1 statement

				//Breakfast Hoagie

				//Breakfast Sandwich

				//Breakfast Sizzli

				system("pause");
				system("cls");

			} //ends Breakfast Menu if statement


			//Lunch Menu
			else if (choice[0] == '2')
			{
				system("cls");
				cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
				cout << ">>                               Lunch Menu                                   >>" << endl;
				cout << ">>                                                                            >>" << endl;
				cout << ">>                       Please Enter Your Selection                          >>" << endl;
				cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;
				system("pause");
				system("cls");
			}


			//Dinner Menu
				else if (choice[0] == '3')
				{
					system("cls");
					cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl;
					cout << ">>                              Dinner Menu                                   >>" << endl;
					cout << ">>                                                                            >>" << endl;
					cout << ">>                       Please Enter Your Selection                          >>" << endl;
					cout << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl << endl << endl << endl;
					system("pause");
					system("cls");
				}


			//Validation
					else if (choice[0] > '3' || choice[0] < '1')
					{
						system("cls");
						cout << "Invalid entry, please enter a number 1-3 corresponding to the menu choice." << endl << endl;
						cout << "Please try again" << endl;
						system("pause");
						system("cls");
					}
		}














	system("pause");
	return 0;
}
Topic archived. No new replies allowed.