Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // The how-to guide. Called first inside int main()
  5. void guide()
  6. {
  7.     cout << "Welcome to Beach Coffee Sells Counter\n\n";
  8.     cout << "======================================================\n\n";
  9.     cout << "How to guide:\nBasically follow the instructions given.\nBut well, here's the full guide\n\n";
  10.     cout << "1. Type in the coffee size that's being ordered\n";
  11.     cout << "2. Type in the amount of coffee that's being ordered\n";
  12.     cout << "3. If there's any other order, type in 1. Otherwise, type in 0\n";
  13.     cout << "4. You can see cups sold, coffee sold, and money earned by typing in 1, 2, or 3.\n";
  14.     cout << "5. You can exit the program by typing in 1 or type 2 to order again (back to order menu)\n\n";
  15.     cout << "======================================================\n\n";
  16. }
  17.  
  18. // Function for choosing size, amount, and cost of each transaction.
  19. void sellCoffee(int (&arr)[3])
  20. {
  21.     int arr1[]={0,0,0};
  22.     int n,m,q;
  23.     const float costsmall=1.75, costmed=1.9, costlarge=2;
  24.     float total;
  25.     cout << "Type 1 for small coffee (9oz, $1.75),\nType 2 for medium coffee (12oz, $1.90),\nType 3 for large coffee(15oz, $2.00).\n\n";
  26.     loop:
  27.     cout << "Coffee Size? "; cin >> n;
  28.     if((n==1) || (n==2) || (n==3))
  29.     cout << "";
  30.     else
  31.     {
  32.         cout << "Try again.\n\n";
  33.         goto loop;
  34.     }
  35.     cout << "Amount to order? "; cin >> m;
  36.     switch(n)
  37.     {
  38.         case 1:
  39.             arr1[0]+=m;
  40.             arr[0]+=m;
  41.             break;
  42.         case 2:
  43.             arr1[1]+=m;
  44.             arr[1]+=m;
  45.             break;
  46.         case 3:
  47.             arr1[2]+=m;
  48.             arr[2]+=m;
  49.             break;
  50.     }
  51.     cout << "Is there anything else? (1) No  (2) Yes  ";
  52.     loop1:
  53.     cin >> q;
  54.     switch(q)
  55.     {
  56.         case 1:
  57.             break;
  58.         case 2:
  59.             goto loop;
  60.             break;
  61.         default:
  62.             goto loop1;
  63.             break;
  64.     }
  65.     total = costsmall*arr1[0] + costmed*arr1[1] + costlarge*arr1[2];
  66.     cout << "That will be $" << total << endl << endl;
  67. }
  68.  
  69. // Function to show each cup size sold
  70. void displayCupSizeSold(int (&arr)[3])
  71. {
  72.     cout << endl;
  73.     cout << "Subtotal " << arr[0] << " small size cup(s) sold.\n\n";
  74.     cout << "Subtotal " << arr[1] << " medium size cup(s) sold.\n\n";
  75.     cout << "Subtotal " << arr[2] << " large size cup(s) sold.\n\n";
  76. }
  77.  
  78. // Function to show (in oz) how many coffee sold
  79. void displayCoffeeSold(int (&arr)[3])
  80. {
  81.     const int small=9,medium=12,large=15;
  82.     int sum = arr[0]*small + arr[1]*medium + arr[2]*large;
  83.     cout << "Total " << sum << "oz coffee sold.\n\n";
  84. }
  85.  
  86. // Function to show the total earning so far
  87. void moneyMade(int (&arr)[3],float &mon)
  88. {
  89.     const float costsmall=1.75, costmed=1.9, costlarge=2;
  90.     mon += arr[0]*costsmall + arr[1]*costmed + arr[2]*costlarge;
  91.     cout << "Money made: $" << mon << "\n\n";
  92. }
  93.  
  94. int main()
  95. {
  96.     float money;
  97.     int cups[]={0,0,0},x,n;
  98.    
  99.     loop:
  100.     guide();
  101.    
  102.     sellCoffee(cups);
  103.    
  104.     loop1:
  105.     cout << "What do you want to do now? (1) Display cups sold  (2) Display coffee sold  (3) Show income  (4) Other  ";
  106.     loop2:
  107.     cin >> n;
  108.     switch(n)
  109.     {
  110.         case 1:
  111.             displayCupSizeSold(cups);
  112.             goto loop1;
  113.             break;
  114.         case 2:
  115.             displayCoffeeSold(cups);
  116.             goto loop1;
  117.             break;
  118.         case 3:
  119.             moneyMade(cups,money);
  120.             goto loop1;
  121.             break;
  122.         case 4:
  123.             cout << endl;
  124.             break;
  125.         default:
  126.             goto loop2;
  127.             break;
  128.     }
  129.    
  130.    
  131.     cout << "Do you want to exit the program? (1) Yes  (2) No (back to order menu)  "; cin >> x;
  132.     switch(x)
  133.     {
  134.         case 1:
  135.             break;
  136.         case 2:
  137.             system ("CLS"); // CLS to clear screen for every transaction
  138.             goto loop;
  139.             break;
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement