You don't need that switch statement. You could replace the entire switch statement with:
1 2 3 4 5 6 7 8
|
cout << "You chose : " << menuList[OrderNumber].menuItem << "..........."\
<< menuList[OrderNumber].menuPrice;
cout << " Would you like to order again? " << endl;
cin >> Y_N;
if (Y_N == 'n' || 'N')
break;
}
|
if (Y_N == 'n' || 'N')
This doesn't do what you think it does. If you want to compare Y_N to two values then you have to do it explicitly:
if (Y_N == 'n' || Y_N == 'N')
Actually, you don't need the if statement at all since the while() condition does the same check (and has the same bug).
Since you want the loop to run at least once, use a do/while loop instead of a while loop.
So with all these changes, the loop looks like:
while (CustomerNumber < 100) { // can only have 100 customers
do {
//showMenu(); // User function that prints out menu informtaion\
for the user to chose order
cout << "You chose : " << menuList[OrderNumber].menuItem
<< "..........."
<< menuList[OrderNumber].menuPrice;
cout << " Would you like to order again? " << endl;
cin >> Y_N;
} while (Y_N == 'y' || Y_N == 'Y'); // While the customer wants to \
order
Now look at CustomerNumber. It defined at line 19, used in the while look at line 29 and incremented at line 65. That's a whole lot of distance for a variable that controls a simple counted loop. You can replace all of those with
for (int CustomerNumber=0; CustomerNumber < 100; ++CustomerNumber) {
Add some temporary code to printCheck() and remove the comment where it's called. Do the same for showMenu(). In other words, you want to be able to test the code that you've written.
Making these changes, the meat of the program looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
for (CustomerNumber = 0; CustomerNumber < 100; ++CustomerNumber) {
do {
showMenu(); // User function that prints out menu informtaion for t\
he user to chose order
cout << "You chose : " << menuList[OrderNumber].menuItem
<< "..........." << menuList[OrderNumber].menuPrice;
cout << " Would you like to order again? " << endl;
cin >> Y_N;
} while (Y_N == 'y' || Y_N == 'Y'); // While the customer wants to\
order
printCheck();
}
|
How does OrderNumber get set?