im trying to complete my getData definition while avoiding an infinate loop
my error right now is that
error C4716: 'getData' : must return a value
i think i need an if statement? can someone show me an example or something?
Code:
#include<iostream>
#include<iomanip>
#include<string>
usingnamespace std;
struct menuItemType
{
string menuItem;
double menuPrice; 
int numOrdered;
};
menuItemType theMenu[8];
void showMenu();
int getData(int choice); 
double Round(double &totalTax); 
void printCheck(double &tax, double &totalBill); 
int choice=0; // The number the user chooses for the item they want 
int number=0; // Used in the getData function
int x=0; // used in "for" loop to initialize numOrdered to 0.
double bill = 0.0; 
double totalBill = 0.0; // w/ tax
double tax = 0.0; 
double taxRate = .05; // tax% 
double totalTax =0.0; 
char shouldContinue; 

 
int main()
{ 

theMenu[0].menuItem = "#1 Plain Egg"; 
theMenu[1].menuItem = "#2 Bacon and Egg";
theMenu[2].menuItem = "#3 Muffin";
theMenu[3].menuItem = "#4 French Toast";
theMenu[4].menuItem = "#5 Fruit Basket";
theMenu[5].menuItem = "#6 Cereal";
theMenu[6].menuItem = "#7 Coffee";
theMenu[7].menuItem = "#8 Tea";
theMenu[0].menuPrice = 1.45; 
theMenu[1].menuPrice = 2.45;
theMenu[2].menuPrice = 0.99;
theMenu[3].menuPrice = 1.99;
theMenu[4].menuPrice = 2.49;
theMenu[5].menuPrice = 0.69;
theMenu[6].menuPrice = 0.50;
theMenu[7].menuPrice = 0.75;
for (x = 0; x < 8; x++) // Initialize theMenu[x].numOrdered to all 0's. 
{
theMenu[x].numOrdered = 0;
}

do
{
showMenu(); // run the void showMenu() function
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

theMenu[choice].numOrdered++; //Add 1 to the amount of the item ordered. 
cout << "\n" << theMenu[choice].numOrdered << setw (20) << theMenu[choice].menuItem << " \n" << endl;
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;
} 
 
 
void showMenu()
{
int x;
for (x = 0; x <=8; x++)
cout << theMenu[x].menuItem << "\t" << theMenu[x].menuPrice << endl; 
}
 
int getData(int choice)
{
while(choice < 0 || choice > sizeof(theMenu)/sizeof(menuItemType))
{
showMenu(); // run the void showMenu() function
cout << "\n" << choice << endl;
int choice = getData(number); // Returns the number the person chose the the array number
}
}
double Round(constdouble &totalTax) //Round to the nearest cent. 
{
double tax;

tax = totalTax * 100.0 + 0.5;
return tax / 100.0;
}
void printCheck(double &tax, double &totalBill)
{
int x;
x = 0;
cout << "Welcome \n" << endl;
for (x = 0; x < 8; x++)
{
if (theMenu[x].numOrdered > 0)
{
cout << theMenu[x].numOrdered << "\t" << theMenu[x].menuItem << "\t" << right << theMenu[x].menuPrice << right << endl; 
}
else 
{
cout << "";
}
}
cout << "Tax" << setw (27) << tax << endl;
cout << "Amount Due" << setw (20) << totalBill << endl;
}