1. ## Restaurant

The problem I'm having is in my getData(int choice) function. I want the function to keep asking the user to enter a valid number (1-8) if they enter something else. If I put an if...else loop there, I can only prevent them from entering the wrong number once.

Code:
```#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

{
int numOrdered;
};

int getData(int choice); // get input from the user
double Round(double &totalTax); // round to the nearest cent
void printCheck(double &tax, double &totalBill); // print what the person ordered and their total check

int main()
{
int choice; //	The number the user chooses for the item they want
int number; // Used in the getData function
int x; // used in "for" loop to initialize numOrdered to 0.
double bill; //	This is the total for items purchased, without tax.
double totalBill; //  This is the total for items purchased, with tax.
double tax; // Amount of one tax after it is rounded.
double taxRate; // Percentage of tax to be charged.
double totalTax; //	Total amount of tax.
char shouldContinue; //	Used to loop the do...while function

totalBill = 0;
taxRate = .05;
tax = 0;
totalTax = 0;
bill = 0;
number = 0;
choice = 0;
x = 0;

theMenu[0].menuItem  = "#1  Plain Egg";	// This part sets the menuItem array  to a numbered food list showing prices.

for (x = 0; x < 8; x++) // Initialize theMenu[x].numOrdered to all 0's.
{
}

do
{
cout << "\n" << endl;

choice = getData(number); // Returns the number the person chose the the array number

bill = theMenu[choice].menuPrice + bill; // Keeps a running total of the bill

cout << "Would you like to place another order?  (Y/N)" << endl; // Allow to purchase more
cin >> shouldContinue;
}
while (shouldContinue == 'Y' || shouldContinue == 'y');
cout << endl;

totalTax = bill * taxRate;

tax = Round(totalTax);

totalBill = bill + tax;

printCheck(tax, totalBill);

return 0;
} //main ()

//***********//
//**********//

{
int x;
for (x = 0; x <=7; x++)
}

//*****************//
// getData(int number)//
//****************//
int getData(int number)
{
int z;
z = 0;
//****** What I'd like to do here is make sure the user chooses a number 1-8.
// I'm not sure how to make a loop that will keep asking them to re-enter a number until they choose a valid choice.*******//
cout << "Please choose a food item by the corresponding number." << endl;
cin >> z;
z = z - 1; // Subtract 1 from the foodChoice to make it match the array.

return z;
}

//*********************//
// Round(double &totalTax)//
//*******************//
double Round(double &totalTax) //Round to the nearest cent.
{
double (tax);

tax = totalTax * 100.0 + 0.5;
return tax / 100.0;
}

//**************************************//
// void printCheck(double &tax, double &totalBill)//
//************************************//
void printCheck(double &tax, double &totalBill)
{
int x;
x = 0;

cout << "Welcome to Johnny's Restaurant \n" << endl;
for (x = 0; x < 8; x++)
{
{
}
else
{
cout << "";
}
}

cout << "Tax" << setw (27) << tax << endl;
cout << "Amount Due" << setw (20) << totalBill << endl;
}```

2. Use the same kind of while loop you managed to use in main()

3. ## enum

In general for this I would write an enumerated list to label the menuItems, then you can use this in a switch statement inside of the suggested while(..) loop, if none of the switch cases are met, ie the user has entered an invalid option, then the default case in the switch can catch this and output the error, otherwise exit the while loop and return the selection.

Code:
```enum itemCode {

PL_EGG,
BC_EGG,
MUFFIN,
FR_TOAST,
//etc
};

//..
//...

bool good2go = false;

while(!good2go)
{
//user inputs selection
//...

switch(selection)
{
case PL_EGG:
{
//set the valid value, whatever
good2go = true;
}
break;

//more cases

default:
//output invalid choice message
break;
}
}```

4. i try that run my program and it end at this progam only.

cout << "Would you like to place another order? (Y/N)" << endl; // Allow to purchase more
cin >> shouldContinue;
}
while (shouldContinue == 'Y' || shouldContinue == 'y');
cout << endl;
why it not continued in the end??