fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <array>
  5. using namespace std;
  6.  
  7. // I Jaime Krogen verify that all of the work below is my own.
  8.  
  9. // Inventory: Global Varibales
  10. // Toppings
  11. int cheese = 200;
  12. int pepperoni = 100;
  13. int mushroom = 100;
  14. int onions = 100;
  15. int sausage = 100;
  16. int hamburger = 100;
  17. int baconBits = 100;
  18. int blackOlives = 100;
  19. int greenPeppers = 100;
  20. int pineapple = 50;
  21. //crust types
  22. int thinCrust = 100;
  23. int flatBread = 100;
  24. int thickCrust = 100;
  25. // Bussiness data
  26. double totalRevenue = 0;
  27. double totalOrderCost = 0;
  28. double totalPizzaCost = 0;
  29.  
  30. int crustCost = 0;
  31. int sizeCost = 0;
  32. int mushroomCost = 0;
  33. int onionsCost = 0;
  34. int baconBitsCost = 0;
  35. int pineappleCost = 0;
  36. // PROBLEM CHILDren so made global
  37. int orderNumSize = 0;
  38. int guestSize = 0;
  39. int numberOfPizzas = 0;
  40.  
  41. // Function displays size of pizza and updates revenue.
  42. void PizzaSize(int numSize, int& sizeCost) {
  43.  
  44. switch(numSize){
  45.  
  46. case 1:
  47. cout << "personal pan";
  48. sizeCost = 10;
  49. break;
  50.  
  51. case 2:
  52. cout << "small";
  53. sizeCost = 10;
  54. break;
  55.  
  56. case 3:
  57. cout << "medium";
  58. sizeCost = 12;
  59. break;
  60.  
  61. case 4:
  62. cout << "large";
  63. sizeCost = 14;
  64. break;
  65.  
  66. case 5:
  67. cout << "extra large";
  68. sizeCost= 14;
  69. break;
  70.  
  71. case 6 :
  72. cout << "NY style";
  73. sizeCost = 16;
  74. break;
  75.  
  76. default:
  77. cout << " invaild number";
  78. }
  79. return;
  80. }
  81.  
  82. // Function displays how many people the pizza can feed.
  83. void feedPeeps(int numPersons) {
  84.  
  85. switch(numPersons){
  86.  
  87. case 1:
  88. cout << "6";
  89. break;
  90. case 2:
  91. cout << "6";
  92. break;
  93. case 3:
  94. cout << "8";
  95. break;
  96. case 4:
  97. cout << "10";
  98. break;
  99. case 5:
  100. cout << "10";
  101. break;
  102. case 6 :
  103. cout << "12";
  104. break;
  105.  
  106. default:
  107. cout << "invaild number";
  108. }
  109. return;
  110. }
  111.  
  112. // Fuction displays crust type, updates inventory and calculates cost for the premium crust .
  113. void crustType(int numCrust, int& crustCost, int& thinCrust, int& flatBread, int&thickCrust) {
  114.  
  115. switch(numCrust){
  116.  
  117. case 1:
  118. cout << "thin crust";
  119. thinCrust--;
  120. crustCost = 0;
  121. break;
  122.  
  123. case 2:
  124. cout << "flatbread";
  125. flatBread -= 1;
  126. crustCost = 0;
  127. break;
  128.  
  129. case 3:
  130. cout << "thick crust";
  131. thickCrust--;
  132. crustCost = 2;
  133. break;
  134.  
  135. default:
  136. cout << " invaild number";
  137. }
  138. return;
  139. }
  140.  
  141. // Function Tells topping choices, updates inventory and calculates cost for premium topping items.
  142. void toppingChoices(int numToppings, int& cheese, int& pepperoni, int& mushroom, int& onions, int& sausage, int& hamburger, int& baconBits, int& blackOlives, int& greenPeppers, int& pineapple, int& mushroomCost, int& onionsCost, int& baconBitsCost, int& pineappleCost){
  143. switch(numToppings){
  144. case 1:
  145. cout << "cheese";
  146. cheese--;
  147. break;
  148.  
  149. case 2:
  150. cout << "pepperoni";
  151. pepperoni--;
  152. break;
  153.  
  154. case 3:
  155. cout << "mushroom";
  156. mushroom--;
  157. mushroomCost++;
  158. break;
  159.  
  160. case 4:
  161. cout << "onions";
  162. onions--;
  163. onionsCost++;
  164. break;
  165.  
  166. case 5:
  167. cout << "sausage";
  168. sausage--;
  169. break;
  170.  
  171. case 6:
  172. cout << "hamburger";
  173. hamburger--;
  174. break;
  175.  
  176. case 7:
  177. cout << "BaconBits";
  178. baconBits--;
  179. baconBitsCost++;
  180. break;
  181.  
  182. case 8:
  183. cout << "blackOlives";
  184. blackOlives--;
  185. break;
  186.  
  187. case 9:
  188. cout << "greenPeppers";
  189. greenPeppers--;
  190. break;
  191.  
  192. case 10:
  193. cout << "pineapple";
  194. pineapple--;
  195. break;
  196.  
  197. }
  198. }
  199.  
  200. //This function checks to make sure a party gets the apporiate size pizza
  201. void partySizeCheck(int& orderNumSize, int& guestSize) {
  202.  
  203. switch (orderNumSize) {
  204. case 1:
  205. case 2:
  206. if (guestSize > 6) {
  207. cout << "Not enough Pizza, please choose a larger size.\n";
  208. }
  209. break;
  210.  
  211. case 3:
  212. if (guestSize > 8) {
  213. cout << "Not enough Pizza, please choose a larger size.\n";
  214. }
  215. break;
  216.  
  217. case 4:
  218. case 5:
  219. if (guestSize > 10) {
  220. cout << "Not enough Pizza, please choose a larger size.\n";
  221. }
  222. break;
  223. case 6:
  224. if (guestSize > 12) {
  225. cout << "Your party is too large how about ordering a second pizza?\n";
  226. }
  227. }
  228. }
  229.  
  230. int main() {
  231.  
  232.  
  233. int orderNumCrust;
  234. int orderNumToppings;
  235. int remainPizza = 0;
  236. char moreToppings;
  237. char displayOrder;
  238. double splitCost;
  239. char splitBill;
  240. char morePizza;
  241.  
  242. double pizzaArray[4];
  243. pizzaArray[0] = 0;
  244. pizzaArray[1] = 0;
  245. pizzaArray[2] = 0;
  246. pizzaArray[3] = 0;
  247.  
  248. do {
  249.  
  250. // Asking about Size & ouputs how many it will feed
  251. cout << "Welcome to Pizza Parlor, please enter a number from 1 to 6 to indicate the size pizza you want\n";
  252. while((orderNumSize > 6) ||(orderNumSize < 1)){
  253. cin >> orderNumSize;
  254. if((orderNumSize > 6)|| (orderNumSize < 1)){
  255. cout << "Enter a number between 1 and 6" << endl;
  256. }
  257. }
  258. cout << "You have chosen to order a ";
  259. PizzaSize(orderNumSize, sizeCost);
  260. cout << ". ";
  261. cout << "This will feed ";
  262. feedPeeps(orderNumSize);
  263. cout << " people." << endl;
  264.  
  265. // Asking about Crust Type
  266. cout << "Please enter a number from 1 to 3 to indicate the type of crust you want.\n";
  267. while(( orderNumCrust > 3) ||( orderNumCrust < 1)){
  268. cin >> orderNumCrust;
  269. if(( orderNumCrust> 3)||( orderNumCrust < 1)){
  270. cout << "Enter a number between 1 and 3" << endl;
  271. }
  272. }
  273. cout << "You have chosen ";
  274. crustType(orderNumCrust, crustCost, thinCrust, flatBread, thickCrust);
  275. cout << " as your crust.\n";
  276.  
  277. // Asking about toppings
  278. cout << "Would your like toppings? (Y=yes, N=no)\n";
  279. cin >> moreToppings;
  280. while (moreToppings == 'Y') {
  281. cout << "Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza\n";
  282. cin >> orderNumToppings;
  283.  
  284. if ((orderNumToppings <= 10) && (orderNumToppings >= 1)) {
  285. cout << "You have added ";
  286. toppingChoices(orderNumToppings, cheese, pepperoni, mushroom, onions, sausage,hamburger, baconBits, blackOlives, greenPeppers, pineapple, mushroomCost, onionsCost, baconBitsCost, pineappleCost);
  287. cout << " to your order. Would you like to add more toppings? (Y = Yes, N = N)\n";
  288. cin >> moreToppings;
  289. }
  290. else {
  291. cout << "Invalid topping number. Please enter a number 1 through 10.\n";
  292. }
  293.  
  294. }
  295. // Adjust party size to correct pizza size
  296. cout << "Please enter the number of guests you have in your party.\n";
  297. cin >> guestSize;
  298. partySizeCheck(orderNumSize, guestSize);
  299. cout << "Great! your party size is " << guestSize << " people." << endl;
  300.  
  301.  
  302. // Calcualtes bill
  303. totalOrderCost = crustCost + sizeCost + mushroomCost + onionsCost + baconBitsCost + pineappleCost;
  304. cout << "Great your total for today’s order at the Pizza Parlor was $" << totalOrderCost << endl;
  305. cout << "Would you like an itemized list of your order? (Y = Yes N = No)" << endl;
  306. cin >> displayOrder;
  307. if (displayOrder == 'Y') {
  308. cout << "Great your itemized total for your order was as follows:\n";
  309. PizzaSize(orderNumSize, sizeCost);
  310. cout << ": " << sizeCost << endl;
  311. crustType(orderNumCrust, crustCost, thinCrust, flatBread, thickCrust);
  312. cout << ": " << crustCost << endl;
  313. cout << "Mushrooms: " << mushroomCost << endl;
  314. cout << "Onions: " << onionsCost << endl;
  315. cout << "Bacon Bits " << baconBitsCost << endl;
  316. cout << "Pineapple: " << pineappleCost << endl;
  317. cout << "Total: " << totalOrderCost << endl;
  318. }
  319.  
  320. /// Splits Bill
  321. cout << "Would you like to split the bill?(Y=yes, N=no)\n";
  322. cin >> splitBill;
  323. if (splitBill == 'Y') {
  324. splitCost = totalOrderCost / guestSize;
  325. cout << "The total cost for each of your " << guestSize << " guests will be $" << splitCost << endl;
  326. }
  327. remainPizza = 3 - numberOfPizzas;
  328.  
  329.  
  330. // Determines if the coustmer wants to order another pizza & exits body
  331. cout << "Would you like to order another pizza? You have " << remainPizza << " pizzas remaining (Y = Yes N = No)." << endl;
  332. cin >> morePizza;
  333. pizzaArray[numberOfPizzas] = totalOrderCost;
  334. numberOfPizzas++;
  335. }while((morePizza == 'Y') && (numberOfPizzas < 4));
  336.  
  337.  
  338. cout << "Thank you for eating at the Pizza Parlor! Please come again soon!\n";
  339.  
  340. // Bussiness inventory and revenue satus.
  341. for (int i = 0; i < 4; i++) {
  342. totalRevenue += pizzaArray[i];
  343. }
  344. cout << "My total revenue for the night was: " << totalRevenue << endl;
  345. cout << "My new QOH totals are as follows:" << endl;
  346. cout << "Cheese: " << cheese << endl;
  347. cout << "Pepperoni: " << pepperoni << endl;
  348. cout << "Mushroom: " << mushroom << endl;
  349. cout << "Onions: " << onions << endl;
  350. cout << "Sauausge: " << sausage << endl;
  351. cout << "Hamburger: " << hamburger << endl;
  352. cout << "Bacon Bits: " << baconBits << endl;
  353. cout << "BlackOlives: " << blackOlives << endl;
  354. cout << "Green Peppers: " << greenPeppers << endl;
  355. cout << "Pineapple: " << pineapple << endl;
  356. cout << "Thin Crust " << thinCrust << endl;
  357. cout << "Flat Bread " << flatBread << endl;
  358. cout << "Thick Crust " << thickCrust << endl;
  359.  
  360.  
  361. return 0;
  362. }
Success #stdin #stdout 0s 5284KB
stdin
6 3 Y 1 Y 2 Y 3 Y 4 Y 5  7 Y Y Y 5 2  Y 6 Y 7 Y 8 Y 9 Y 10  9 Y N N
stdout
Welcome to Pizza Parlor, please enter a number from 1 to 6 to indicate the size pizza you want
You have chosen to order a NY style. This will feed 12 people.
Please enter a number from 1 to 3 to indicate the type of crust you want.
You have chosen thick crust as your crust.
Would your like toppings? (Y=yes, N=no)
Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza
You have added cheese to your order. Would you like to add more toppings? (Y = Yes, N = N)
Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza
You have added pepperoni to your order. Would you like to add more toppings? (Y = Yes, N = N)
Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza
You have added mushroom to your order. Would you like to add more toppings? (Y = Yes, N = N)
Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza
You have added onions to your order. Would you like to add more toppings? (Y = Yes, N = N)
Please enter a number from 1 to 10 to indicate what toppings you would like on your pizza
You have added sausage to your order. Would you like to add more toppings? (Y = Yes, N = N)
Please enter the number of guests you have in your party.
Great! your party size is 0 people.
Great your total for today’s order at the Pizza Parlor was $20
Would you like an itemized list of your order? (Y = Yes N = No)
Would you like to split the bill?(Y=yes, N=no)
Would you like to order another pizza? You have 3 pizzas remaining (Y = Yes N = No).
Thank you for eating at the Pizza Parlor! Please come again soon!
My total revenue for the night was: 20
My new QOH totals are as follows:
Cheese: 199
Pepperoni: 99
Mushroom: 99
Onions: 99
Sauausge: 99
Hamburger: 100
Bacon Bits: 100
BlackOlives: 100
Green Peppers: 100
Pineapple: 50
Thin Crust 100
Flat Bread 100
Thick Crust 99