im trying to make a restaurant menu program but i keep getting
"expected constructor, destructor, or type conversion before '<<' token" when i compile. any all would be much appreciated
/*
Name: Paul Pee
Date: 2/11/12
Description: Breakfast Programs
*/
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct menuItem
{
string menuChoice;
double menuPrice;
};
struct selectedItem
{
string menuChoice;
double menuPrice;
};
void getData(menuItem menuList[7]) //Loading data into the struct
{
menuList[0].menuChoice="Plain Egg";
menuList[0].menuPrice = 1.45;
menuList[1].menuChoice = "Bacon and Egg";
menuList[1].menuPrice = 2.45;
menuList[2].menuChoice = "Muffin";
menuList[2].menuPrice = 0.99;
menuList[3].menuChoice = "French Toast";
menuList[3].menuPrice = 1.99;
menuList[4].menuChoice = "Cereal";
menuList[4].menuPrice = 1.69;
menuList[5].menuChoice = "Coffee";
menuList[5].menuPrice = 1.25;
menuList[6].menuChoice = "Tea";
menuList[6].menuPrice = 1.25;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void showMenu(menuItem menuList[7]) //function shows a customer to select items from the menu
{
cout << "What would you like for breakfast?"<<endl;
for (int i=0;i<7;i++)
{
cout << i+1 << ": " << left << setw(18) <<menuList[i].menuChoice << right << setw(14) << menuList[i].menuPrice << endl;
}
cout<<"Hit 0 to complete your order" << endl;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
double iTotal ( double price , int amt)
{
double sp;
sp = price * amt;
return (sp);
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void printCheck(menuItem menuList[7])
{
int amt;
double price;
double eggtotal, mtotal, betotal, cetotal, cototal, fttotal, ttotal =0;
double total = 0.0;
int amtegg, amtbe, amtm, amtft, amtce, amtco, amtt = 0;
int choice = 9;
double tax = 0.05;
double pretotal = eggtotal + betotal + mtotal + fttotal + cetotal + cototal +ttotal;
double taxamt = pretotal * tax;
double fnltotal = pretotal + tax;
selectedItem selectedChoice[7];
for(int e=0;e<7;e++)
{
selectedChoice[e].menuChoice=' ';
selectedChoice[e].menuPrice=0;
}
cout << "Please make your selections." << endl;
while (choice != 0)
cin >> choice;
switch(choice)
{
case 1:
cout << setw(53)<< menuList[0].menuChoice <<" " << menuList[0].menuPrice<<endl;
if (amtegg == 0)
{
selectedChoice[0].menuPrice=menuList[0].menuPrice;
selectedChoice[0].menuChoice=menuList[0].menuChoice;
amtegg++;
}
else
amtegg++;
price = menuList[0].menuPrice;
amt = amtegg;
eggtotal = iTotal (price, amt);
break;
case 2:
cout << setw(53)<< menuList[1].menuChoice <<" " << menuList[1].menuPrice<<endl;
if (amtbe == 0)
{
selectedChoice[1].menuPrice=menuList[1].menuPrice;
selectedChoice[1].menuChoice=menuList[1].menuChoice;
amtbe++;
}
else
amtbe++;
price = menuList[1].menuPrice;
amt = amtbe;
betotal = iTotal (price, amt);
break;
case 3:
cout << setw(53)<< menuList[2].menuChoice <<" " << menuList[2].menuPrice<<endl;
if (amtm == 0)
{
selectedChoice[2].menuPrice=menuList[2].menuPrice;
selectedChoice[2].menuChoice=menuList[2].menuChoice;
amtm++;
}
else
amtm++;
price = menuList[2].menuPrice;
amt = amtm;
mtotal = iTotal (price, amt);
break;
case 4:
cout << setw(53)<< menuList[3].menuChoice <<" " << menuList[3].menuPrice<<endl;
if (amtft == 0)
{
selectedChoice[3].menuPrice=menuList[3].menuPrice;
selectedChoice[3].menuChoice=menuList[3].menuChoice;
amtft++;
}
else
amtft++;
price = menuList[3].menuPrice;
amt = amtft;
fttotal = iTotal (price, amt);
break;
case 5:
cout << setw(53)<< menuList[4].menuChoice <<" " << menuList[4].menuPrice<<endl;
if (amtce == 0)
{
selectedChoice[4].menuPrice=menuList[4].menuPrice;
selectedChoice[4].menuChoice=menuList[4].menuChoice;
amtce++;
}
else
amtce++;
price = menuList[4].menuPrice;
amt = amtce;
cetotal = iTotal (price, amt);
break;
case 6:
cout << setw(53)<< menuList[5].menuChoice <<" " << menuList[5].menuPrice<<endl;
if (amtco == 0)
{
selectedChoice[5].menuPrice=menuList[5].menuPrice;
selectedChoice[5].menuChoice=menuList[5].menuChoice;
amtco++;
}
else
amtco++;
price = menuList[5].menuPrice;
amt = amtco;
cototal = iTotal (price, amt);
break;
case 7:
cout << setw(53)<< menuList[6].menuChoice <<" " << menuList[6].menuPrice<<endl;
if (amtt == 0)
{
selectedChoice[6].menuPrice=menuList[6].menuPrice;
selectedChoice[6].menuChoice=menuList[6].menuChoice;
amtt++;
}
else
amtt++;
price = menuList[6].menuPrice;
amt = amtt;
ttotal = iTotal (price, amt);
break;
case 0:
break;
default:
cout << "That choice is not on the menu!!" << endl;
break;
}
}
cout << " Welcome to Johnny's Restaurant "<<endl;
cout << " Your Bill "<<endl;
cout << endl;
cout << setw(20)<<"Menu Item "<<setw(20)<<"Price(USD $)"<<endl;
for(int f=0;f<7;f++) //Extracts data from struct 2 and outputs them on the screen
{
if (selectedChoice[f].menuChoice==" ")
f++;
else
cout<<setw(20)<<selectedMenu[f].menuChoice<<setw(20)<<selectedChoice[f].menuPrice<<endl;
}
cout<<endl;
cout<<setw(20)<<"Taxes"<<setprecision(2)<<setw(35) <<taxamt<<endl;
cout<<endl;
cout<<setw(20)<<"Amount Due"<<setprecision(3)<<setw(35)<<fnltotal<<endl;
cout<<endl;
}
int main()
{
menuItem menuList[7];
getData(menuList);
showMenu(menuList);
printCheck(menuList);
system("Pause");
return 0;
}