Hi I'm a programming student working on this sample restaurant menu.
The problem im having is when the user enters invalid input the program is supposed to re-ask the question. Closest I've gotten is the FIRST and LAST option of each switch work semi correctly ( I would like it if it only asked the problem question but it restarts the entire loop ) but the MIDDLE cases just roll on through here is a snip of what works and what doesnt:
(I have tried adding 'break;' to the 'default:' case but no affect)
cout << "Please enter the number of people in your party. \n";
cin >> party;
while (count <= party)
{//Start Count
cout << endl << "May I ask who I'm serving today? ";
cin >> name;
cout << endl << "Hello " << name <<", May I take your order? \n
cout << "Enter (A) for Pizza | (B) for Pasta | (C) for Salad. \n";
cin >> meal; // Invalid input here takes you to the right place.
switch (meal)
{//Start Meal Switch
case 'A':
case 'a':
{//Start Pizza Switch
cout << endl << "You chose Pizza! \nSo " << name <<" what would you like for your topping? \n
cout << Toppings - Please enter (A) for Pepperoni | (B) for Anchovies | (C) for Plain \n";
cin >> topping; //Invalid input here is where help is needed
switch (topping)
{//Start Topping Switch
case 'A':
case 'a':
total = total + 1.00;
cout << endl << "You chose Pepperoni! \n";
break;
case 'B':
case 'b':
total = total + 2.00;
cout << endl << "You chose Anchovies! \n";
break;
case 'C':
case 'c':
cout << endl << "You chose Plain Cheese! \n";
break;
default:
cout << endl << "Invalid Choice. \nPlease start over. \n";
}//End Topping Switch
cout << "Now " << name <<" the Size! \n";
cout << "Size - Please enter (A) for Small | (B) for Medium | (C) for Large \n";
cin >> size;//Invalid input here takes you to the right place
switch (size)
{//Start Size Switch
case 'A':
case 'a':
total = total + 8.00;
cout << endl << "You chose Small! \nIs this correct? \nPlease enter: \nY for Yes \nN for No";
cin >> order;
if (order == 'y')
{
count++;
}
break;
case 'B':
case 'b':
total = total + 12.00;
cout << endl << "You chose Medium! \nIs this correct? \nPlease enter: \nY for Yes \nN for No";
cin >> order;
if (order == 'y')
{
count++;
}
break;
case 'C':
case 'c':
total = total + 15.00;
cout << endl << "You chose Large! \nIs this correct? \nPlease enter: \nY for Yes \nN for No";
cin >> order;
if (order == 'y')
{
count++;
}
break;
default:
cout << endl << "Invalid Choice. \nPlease start over. \n";
break;
}//End Size Switch
break;
}//End Pizza Switch