Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. struct menuType {
  8. string Item;
  9. double price;
  10. };
  11.  
  12. void showMenu( menuType menuList[], int );
  13. void getdata( menuType menuList[] );
  14. void printCheck(menuType menuList[], int, double );
  15. vector<int> askOrder();
  16. int main()
  17. {
  18. const int item = 8;
  19. const double tax = 0.05;
  20. int orderSelect = 0;
  21. bool order = true;
  22. int choice;
  23. int selection = 0;
  24. int menuOrder[item];
  25. menuType menuList[item];
  26.  
  27. getdata(menuList);
  28. showMenu(menuList, item);
  29.  
  30. printCheck(menuList, selection, tax);
  31.  
  32.  
  33. return 0;
  34. }
  35.  
  36. void getdata( menuType menuList[] )
  37. {
  38. //declare variable
  39. menuType PlainEgg;
  40. menuType BaconEgg;
  41. menuType Muffin;
  42. menuType FrenchToast;
  43. menuType FruitBasket;
  44. menuType Cereal;
  45. menuType Coffee;
  46. menuType Tea;
  47.  
  48. //assign name to each item
  49. PlainEgg.Item = "Plain Egg";
  50. BaconEgg.Item = "Bacon Egg";
  51. Muffin.Item = "Muffin";
  52. FrenchToast.Item = "French Toast";
  53. FruitBasket.Item = "Fruit Basket";
  54. Cereal.Item = "Cereal";
  55. Coffee.Item = "Coffee";
  56. Tea.Item = "Tea";
  57.  
  58. //assign price to each item
  59. PlainEgg.price = 1.45;
  60. BaconEgg.price = 2.45;
  61. Muffin.price = 0.99;
  62. FrenchToast.price = 1.99;
  63. FruitBasket.price = 2.49;
  64. Cereal.price = 0.69;
  65. Coffee.price = 0.50;
  66. Tea.price = 0.75;
  67.  
  68. //put variable into array
  69. menuList[0] = PlainEgg;
  70. menuList[1] = BaconEgg;
  71. menuList[2] = Muffin;
  72. menuList[3] = FrenchToast;
  73. menuList[4] = FruitBasket;
  74. menuList[5] = Cereal;
  75. menuList[6] = Coffee;
  76. menuList[7] = Tea;
  77. }
  78.  
  79.  
  80. void showMenu( menuType menuList[], int x )
  81. {
  82.  
  83. for( int i = 0; i < x; i++ )
  84. {
  85.  
  86. cout << left << "[" << i+1 << "]";
  87. cout << menuList[i].Item;
  88. cout.width(6);
  89. cout <<"\t" << "\t"<< "\t" << "$" << menuList[i].price << endl;
  90.  
  91. }
  92.  
  93. }
  94. vector<int> askOrder() {
  95. while ture;
  96. cin << order;
  97. vector < int > history;
  98. history.push_back(order)
  99. if order >= 1 && order < 9
  100. return history;
  101. }
  102. //to calculate the bill
  103. void printCheck(menuType menuList[], int seleciton, double tax, int menuOder[], int item) {
  104. cout << "welcome to Johns restaurant" << endl;
  105. cout << "Please select your item and enter 9 to exit" << endl;
  106. menuList->Item;
  107. int total;
  108. int selections = 0;
  109. int item = 8;
  110. int menuOrder[8];
  111.  
  112. while (selections != 9)
  113. {
  114. double tax=0.05;
  115. double total = 0 ;
  116. double itemPrice= 0 ;
  117. total = itemPrice + tax *itemPrice;
  118. cout << "Enter your selections: ";
  119.  
  120. selections += selections;
  121. cin >> selections;
  122.  
  123. switch (selections)
  124. {
  125. case 9:
  126. break;
  127. case 1:
  128. cout << menuList[0].Item << setw(14) << " " << "$1.45";
  129. break;
  130. case 2:
  131. cout << menuList[1].Item << setw(10) << " " << "$2.45";
  132. break;
  133. case 3:
  134. cout << menuList[2].Item << setw(17) << " " << "$0.99";
  135. break;
  136. case 4:
  137. cout << menuList[3].Item << setw(11) << " " << "$1.99";
  138. break;
  139. case 5:
  140. cout << menuList[4].Item << setw(11) << " " << "$2.49";
  141. break;
  142. case 6:
  143. cout << menuList[5].Item << setw(17) << " " << "$0.69";
  144. break;
  145. case 7:
  146. cout << menuList[6].Item << setw(17) <<" " << "$0.50";
  147. break;
  148. case 8:
  149. cout << menuList[7].Item << setw(20) <<" " << "$0.75";
  150. break;
  151. default:
  152. cout << "Selections must be between 1 and 8\n";
  153. break;
  154. }
  155. }
  156. bool order = true;
  157. cout << "Thanks for eating at Bob Evans!"
  158. cout << "Customer check: " << endl;
  159.  
  160. total = total + tax;
  161. cout << "\nWelcome to Josh's Restaurant" << endl;
  162. cout << "Tax" << setw(10) << endl;
  163. cout << "Amount Due" << setw(10) << endl;
  164.  
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement