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
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const double SALESTAX = .05;
double totalAmount;
struct menuItemType
{
char menuItem[20];
double menuPrice, quantity;
}menuList[8], itemQuantity[8], customerOrderList[8];
void getData(menuItemType menuList[8]);
void showMenu(menuItemType menuList[8], menuItemType customerOrderList[8], menuItemType itemQuantity[8], int counter, int menuSelection);
void printCheck(menuItemType customerOrderList[8], menuItemType itemQuantity[8], int counter, const int SALESTAX, double totalAmount);
int main()
{
int counter = 0;
int menuSelection = ' ';
double totalAmount = 0;
getData(menuList);
showMenu(menuList, customerOrderList, itemQuantity, counter, menuSelection);
printCheck(customerOrderList, itemQuantity, counter, SALESTAX, totalAmount);
return 0;
}
void getData(menuItemType menuList[8])
{
strcpy(menuList[0].menuItem,"Plain Egg");
menuList[0].menuPrice = 1.45;
strcpy(menuList[1].menuItem,"Bacon and Egg");
menuList[1].menuPrice = 2.45;
strcpy(menuList[2].menuItem,"Muffin");
menuList[2].menuPrice = 0.99;
strcpy(menuList[3].menuItem,"French Toast");
menuList[3].menuPrice = 1.99;
strcpy(menuList[4].menuItem,"Fruit Basket");
menuList[4].menuPrice = 2.49;
strcpy(menuList[5].menuItem,"Cereal");
menuList[5].menuPrice = 0.69;
strcpy(menuList[6].menuItem,"Coffee");
menuList[6].menuPrice = 0.50;
strcpy(menuList[7].menuItem,"Tea");
menuList[7].menuPrice = 0.75;
}
void showMenu(menuItemType menuList[8], menuItemType customerOrderList[8], menuItemType itemQuantity[8], int counter, int menuSelection)
{
cout << "Enter the number of your menu item selections one at a time. When you have completed your order, enter 0 to print your check.";
cout << endl;
cout << "1 - Plain Egg" << setw(14) << "$1.45";
cout << endl;
cout << "2 - Bacon and Egg" << setw(10) << "$2.45";
cout << endl;
cout << "3 - Muffin" << setw(17) << "$0.99";
cout << endl;
cout << "4 - French Toast" << setw(11) << "$1.99";
cout << endl;
cout << "5 - Fruit Basket" << setw(11) << "$2.49";
cout << endl;
cout << "6 - Cereal" << setw(17) << "$0.69";
cout << endl;
cout << "7 - Coffee" << setw(17) << "$0.50";
cout << endl;
cout << "8 - Tea" << setw(20) << "$0.75";
cout << endl;
do
{
int menuSelection;
cin >> menuSelection;
switch(menuSelection)
{
case 1:
cout << "Enter quantity of " << "'" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 2:
cout << "Enter quantity of " << "'" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 3:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 4:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 5:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 6:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 7:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 8:
cout << "Enter quantity of '" << menuList[menuSelection-1].menuItem << "'";
cout << endl;
cin >> itemQuantity[menuSelection-1].quantity;
break;
case 0:
break;
default:
cout << "Enter the number of a menu item 1-8 or enter 0 to continue. ";
cout << endl;
}
}
while(menuSelection != 0);
if(menuSelection >= 0 && menuSelection <=8)
{
strcpy(customerOrderList[counter].menuItem,menuList[menuSelection-1].menuItem);
customerOrderList[counter].menuPrice = menuList[menuSelection-1].menuPrice;
counter++;
}
else if(menuSelection == 0)
{
cout << "Your order is complete. ";
cout << endl;
}
}
void printCheck(menuItemType customerOrderList[8], menuItemType itemQuantity[8], int counter, const int SALESTAX, double totalAmount)
{
totalAmount = customerOrderList[0].menuPrice + customerOrderList[1].menuPrice + customerOrderList[2].menuPrice + customerOrderList[3].menuPrice + customerOrderList[4].menuPrice + customerOrderList[5].menuPrice + customerOrderList[6].menuPrice + customerOrderList[7].menuPrice;
cout << "Welcome to Johnny's Restaraunt";
cout << endl;
for(counter=0;counter<8;counter++)
{
if(itemQuantity[counter].quantity = 0)
{
}
else
{
switch(counter)
{
case 0:
cout << itemQuantity[0].quantity << setw(2) << customerOrderList[0].menuItem << setw(14) << "$" << customerOrderList[0].menuPrice << endl;
case 1:
cout << itemQuantity[1].quantity << setw(2) << customerOrderList[1].menuItem << setw(10) << "$" << customerOrderList[1].menuPrice << endl;
case 2:
cout << itemQuantity[2].quantity << setw(2) << customerOrderList[2].menuItem << setw(17) << "$" << customerOrderList[2].menuPrice << endl;
case 3:
cout << itemQuantity[3].quantity << setw(2) << customerOrderList[3].menuItem << setw(11) << "$" << customerOrderList[3].menuPrice << endl;
case 4:
cout << itemQuantity[4].quantity << setw(2) << customerOrderList[4].menuItem << setw(11) << "$" << customerOrderList[4].menuPrice << endl;
case 5:
cout << itemQuantity[5].quantity << setw(2) << customerOrderList[5].menuItem << setw(17) << "$" << customerOrderList[5].menuPrice << endl;
case 6:
cout << itemQuantity[6].quantity << setw(2) << customerOrderList[6].menuItem << setw(17) << "$" << customerOrderList[6].menuPrice << endl;
case 7:
cout << itemQuantity[7].quantity << setw(2) << customerOrderList[7].menuItem << setw(20) << "$" << customerOrderList[7].menuPrice << endl;
}
}
}
cout << "Tax" << setw(19) << "$" << (totalAmount * SALESTAX) << endl;
cout << "Amount Due" << setw(12) << "$" << (totalAmount + (totalAmount * SALESTAX));
}
|