1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
using namespace std;
ofstream outs; //Declare outs globally so that you can access it in the
//functions directly
int main()
{
int num1, //number of Buffalo Wings ordered by a single customer
num2, //number of Super Burgers ordered by a single customer
num3, //number of Italian Sandwiches ordered by a single customer
num4, //number of Shrimp Nuggets ordered by a single customer
num5, //number of Veggie Supremes ordered by a single customer
customers; //number of customers
int total1, //total number of Buffalo Wings ordered for the day
total2, //total number of Super Burgers ordered for the day
total3, //total number of Italian Sandwiches ordered for the day
total4, //total number of Shrimp Nuggets ordered for the day
total5; //total number of Veggie Supremes ordered for the day
//Function Prototypes
void describe_program();
void display_menu();
void get_order(int& num1,int& num2,int& num3, int& num4, int& num5);
void compute_display_bill(int num1, int num2, int num3, int num4, int num5);
void compute_totals(int num1, int num2, int num3, int num4, int num5 );
bool another();
void summary( int customers);
//open external file
outs.open("food_court.txt",ios::app);
describe_program();
//Initialize variables
total1 = 0, total2 = 0, total3 = 0, total4 = 0, total5 = 0, customers = 0;
do //processing of a customer
{
customers++;
//update customer count
display_menu();
//display the menu
get_order(num1,num2,num3, num4,num5);
//get order from the customer
compute_display_bill(num1, num2,num3, num4, num5);
//Indicate the customer number at external file
compute_totals(num1,num2,num3,num4, num5);
//compute and display the customer's bill at the screen and external file
//compute totals so far
}while(another()); //while there is another customer
summary(customers);
//print a daily summary at the screen and external file
outs.close();
system("PAUSE");
return 0;
}
//Define functions here
//You write the code! It's similar to the function again()
void describe_program()
{
cout<<"This program will ask you to place an order at a fast food restaurant.\n"
<<"There are 5 items on the menu including buffalo wings, a Super burger,\n"
<<"an Italian sandwich, shrimp nuggets and a veggie supreme. You will\n"
<<"enter your choice according to the corresponding order numbers on each\n"
<<"item. You may order as many items as you like. When the days orders\n"
<<"are complete, enter 0 and the program will calculate the total amount\n"
<<"of money, items, amount each item cost and the total number of \n"
<<"customers for that day. All of this information will be shown at the \n"
<<"screen and sent to the external file food_court.txt.\n\n";
//You write the code
return;
}
void display_menu()
{
cout<<"Welcome to the best restaurant! Please have a look at our menu and make\n"
<<"your choice.\n"
<<"1 - Buffalo Wings - $6.95\n"
<<"2 - Super Burger - $5.75\n"
<<"3 - Italian Sandwich - $7.25\n"
<<"4 - Shrimp Nuggets - $8.95\n"
<<"5 - Veggie Supreme - $4.95\n";
//Display menu of items and get order
//You write the code
return;
}
void get_order(int& num1,int& num2,int& num3, int& num4, int& num5)
{
const int Sentinel = 0;
int choice, //menu choice made by customer
num; //number of a particular food item ordered by a customer
cout<<"Which item would like like? Please enter the item number:";
cin>>choice;
//Initialize num1, num2 etc. You write the code!
num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0;
while (choice!=Sentinel)
{
switch (choice)
{
case 1:
cout<<"How many of this item would you like? Please enter an amount:";
cin>>num;
num1+=num;
break;
case 2:
cout<<"How many of this item would you like? Please enter an amount:";
cin>>num;
num2+=num;
break;
case 3:
cout<<"How many of this item would you like? Please enter an amount:";
cin>>num;
num3+=num;
break;
case 4:
cout<<"How many of this item would you like? Please enter an amount:";
cin>>num;
num4+=num;
break;
case 5:
cout<<"How many of this item would you like? Please enter an amount:";
cin>>num;
num5+=num;
break;
default: cout<<"You have entered an invalid menu item! Please enter a valid\n"
<<"number\n";
}
cout<<"Please enter an item number or 0 to complete your order:";
cin>>choice;
//Process customer order. Use a while loop with a senatinel value of 0.
//Use a switch statement to ask how many of the selection the customer
//wants and update the number of that food item by the number ordered by the
//customer
//You write the code!
return;
}
void compute_display_bill(int num1, int num2, int num3, int num4, int num5);
{
const double price1 = 6.95, //price of Buffalo Wings
price2 = 5.75, //price of Super Burgers
price3 = 7.25, //price of Italian Sandwich
price4 = 8.95, //price of Shrimp Nuggets
price5 = 4.95; //price of Veggie Supreme
double cost1, //cost of num1 Buffalo Wings
cost2, //cost of num2 Super Burgers
cost3, //cost of num3 Italian Sandwiches
cost4, //cost of num4 Shrimp Nuggets
cost5, //cost of num5 Veggie Supremes
totcost; //total cost of the order
cost1 = num1*price1;
cost2 = num2*price2;
cost3 = num3*price3;
cost4 = num4*price4;
cost5 = num5*price5;
totcost = cost1+cost2+cost3+cost4+cost5;
cout<<"The total cost for this order is "<<totcost<<".\n";
//You write the code that computes the above costs and displays them
//at the screen and the external file!
return;
}
void compute_totals(int num1, int num2, int num3, int num4, int num5,
int& tot1, int& tot2, int& tot3, int& tot4, int& tot5);
{
tot1+=num1;
tot2+=num2;
tot3+=num3;
tot4+=num4;
tot5+=num5;
//You write the code that updates the number of each food item that
//has been sold so far today by using the number of each food item
//that was ordered by a customer
return;
}
void summary(int tot1, int tot2, int tot3, int tot4, int tot5, int customers);
{
const double price1 = 6.95,
price2 = 5.75,
price3 = 7.25,
price4 = 8.95,
price5 = 4.95;
double sale1, //sale amount of Buffalo Wings for the day
sale2, //sale amount of Super Burgers for the day
sale3, //sale of Italian Sandwiches for the day
sale4, //sale of Shrimp Nuggets for the day
sale5, //sale of Veggie Supremes for the day
totsales;//total sales for the day
sale1 = tot1*price1;
sale2 = tot2*price2;
sale3 = tot3*price3;
sale4 = tot4*price4;
sale5 = tot5*price5;
totsales = sale1+sale2+sale3+sale4+sale5;
|