Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. struct menuItemType
  7. {
  8.     string menuItem[10];
  9.     float menuPrice[10];
  10. };
  11.  
  12. //show data
  13. void showmenu();
  14.  
  15. //get data
  16. void getData(menuItemType & mList, int & c);
  17.  
  18. //print check
  19. void printCheck(menuItemType & mList, int & c);
  20.  
  21. int main()
  22. {
  23.     menuItemType menuList;
  24.     int c;
  25.     showmenu();
  26.     getData(menuList, c);
  27.     printCheck(menuList, c);
  28. }
  29.  
  30. void showmenu()
  31. {
  32.     cout << "Welcome to Johnny's Restaurant" << endl;
  33.     cout << "\n1. Plain Egg" << "\t\t" << "$1.45" << endl;
  34.     cout << "2. Bacon and Egg" << "\t" << "$2.45" << endl;
  35.     cout << "3. Muffin" << "\t\t" << "$0.99" << endl;
  36.     cout << "4. French Toast" << "\t\t" << "$1.99" << endl;
  37.     cout << "5. Fruit Basket" << "\t\t" << "$2.49" << endl;
  38.     cout << "6. Cereal" << "\t\t" << "$0.69" << endl;
  39.     cout << "7. Coffee" << "\t\t" << "$0.50" << endl;
  40.     cout << "8. Tea" << "\t\t\t" << "$0.75" << endl;
  41. }
  42.  
  43. void getData(menuItemType & mList, int & c)
  44. {
  45.     int choice;
  46.  
  47.     cout << "\nEnter the total number of items selected: ";
  48.     cin >> c;
  49.  
  50.     cout << "\nEnter the items selected:" << endl;
  51.     cout << setprecision(2) << fixed;
  52.     for (int i = 0; i < c; i++)
  53.     {
  54.         cin >> choice;
  55.         switch (choice)
  56.         {
  57.         case 1: mList.menuItem[i] = "Plain Egg";
  58.                 mList.menuPrice[i] = 1.45;
  59.             break;
  60.         case 2: mList.menuItem[i] = "Bacon and Egg";
  61.                 mList.menuPrice[i] = 2.45;
  62.             break;
  63.         case 3: mList.menuItem[i] = "Muffin\t";
  64.                 mList.menuPrice[i] = 0.99;
  65.             break;
  66.         case 4: mList.menuItem[i] = "French Toast";
  67.                 mList.menuPrice[i] = 1.99;
  68.             break;
  69.         case 5: mList.menuItem[i] = "Fruit Basket";
  70.                 mList.menuPrice[i] = 2.49;
  71.             break;
  72.         case 6: mList.menuItem[i] = "Cereal\t";
  73.                 mList.menuPrice[i] = 0.69;
  74.             break;
  75.         case 7: mList.menuItem[i] = "Coffee\t";
  76.                 mList.menuPrice[i] = 0.50;
  77.             break;
  78.         case 8: mList.menuItem[i] = "Tea\t";
  79.                 mList.menuPrice[i] = 0.75;
  80.             break;
  81.         }//end of switch
  82.     }//end of for loop
  83. }//end of get data
  84.  
  85. void printCheck(menuItemType & mList, int & c)
  86. {
  87.     float price = 0.0, tax = 0.0, total = 0.0;
  88.  
  89.     cout << "\nWelcome to Johnny's Restaurant" << endl;
  90.     for (int i = 0; i < c; i++)
  91.     {
  92.         cout << mList.menuItem[i] << "\t" << mList.menuPrice[i] << endl;
  93.         price += mList.menuPrice[i];
  94.     }
  95.     tax = 0.05 * price;
  96.     total = tax + price;
  97.     cout << setprecision(2) << fixed;
  98.     cout << "\nTax= $" << tax << endl;
  99.     cout << "Amount Due= $" << total << endl;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement