Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5. struct menuType {
  6. string Item;
  7. double price;
  8. };
  9. void outputMenu(menuType menuList[], int);
  10. void getdata(menuType menuList[]);
  11.  
  12. int main() {
  13. const int item = 8;
  14.  
  15. menuType menuList[item];
  16. getdata(menuList);
  17. outputMenu(menuList, item);
  18.  
  19.  
  20.  
  21. return 0;
  22. }
  23. void getdata(menuType menuList[]) {
  24. //declare variable
  25. menuType PlainEgg;
  26. menuType BaconEgg;
  27. menuType Muffin;
  28. menuType FrenchToast;
  29. menuType FruitBasket;
  30. menuType Cereal;
  31. menuType Coffee;
  32. menuType Tea;
  33. //assign name to each item
  34. PlainEgg.Item = "Plain Egg";
  35. BaconEgg.Item = "Bacon Egg";
  36. Muffin.Item = "Muffin";
  37. FrenchToast.Item = "French Toast";
  38. FruitBasket.Item = " Fruit Basket";
  39. Cereal.Item = "Cereal";
  40. Coffee.Item = "Coffee";
  41. Tea.Item = "Tea";
  42. //assign price to each item
  43. PlainEgg.price = 1.45;
  44. BaconEgg.Item = 2.45;
  45. Muffin.Item = 0.99;
  46. FrenchToast.price = 1.99;
  47. FruitBasket.Item = 2.49;
  48. Cereal.price = 0.69;
  49. Coffee.price = 0.50;
  50. Tea.price = 0.75;
  51. //put variable into array
  52. menuList[0] = PlainEgg;
  53. menuList[1] = BaconEgg;
  54. menuList[2] = Muffin;
  55. menuList[3] = FrenchToast;
  56. menuList[4] = FruitBasket;
  57. menuList[5] = Cereal;
  58. menuList[6] = Coffee;
  59. menuList[7] = Tea;
  60.  
  61.  
  62.  
  63. }
  64.  
  65.  
  66. void outputMenu(menuType menuList[], int x) {
  67. for (int i = 0; i < x; i++) {
  68. cout << setw(2) << left << "[" << i++ << "]";
  69. cout << menuList[i].Item << endl;
  70. cout << "$" << menuList[i].price << endl;
  71. }
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement