SHARE
TWEET

Untitled

a guest Nov 15th, 2019 90 in 104 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. void tutorial () {
  7.     cout << "\nTutorial\n";
  8.     cout << setw(9) << "=\n";
  9.     cout << "Don't worry, our program is user-friendly! \nWhen the program requires an input from you, \nyou only need to enter the relevant digit that are shown later. \nFor example, in the MAIN MENU, you can see that number 5 is assigned to \"Exit the program\", \nAs such, when you enter the number 5, you will close this program. Good luck! \n\n";
  10.    
  11. }
  12.  
  13. void mainmenu () {
  14.     cout << "MAIN MENU" << endl;
  15.     cout << setw(9) << "=" << endl;
  16.     cout << "1. Buy Coffee \n";
  17.     cout << "2. Number of cups sold \n";
  18.     cout << "3. Amount of coffee sold \n";
  19.     cout << "4. Amount of money made \n";
  20.     cout << "5. Exit program \n\n";
  21.     cout << "What would you like to do? ";
  22. }
  23.  
  24. void buy (int &small, int &medium, int &large) {
  25.     int order = 0, amount;
  26.     cout << "\nCOFFEE\n" ;
  27.     cout << setw(7) << "=\n";
  28.     cout << "1. Small\n2. Medium\n3. Large\n4. Back\n";
  29.     do {
  30.         cout << "\nWhich size would you like to order? ";
  31.         cin >> order;
  32.         if (order < 1 || order > 4) {
  33.             cout << "That input was not understood, please try again. ";
  34.         } else if (order == 4) {
  35.             cout << "Going back to main menu....\n";
  36.         } else {
  37.             cout << "How many? ";
  38.             cin >> amount;
  39.             if (order == 1) {
  40.                 small += amount;
  41.             } else if (order == 2) {
  42.                 medium += amount;
  43.             } else if (order == 3) {
  44.                 large += amount;
  45.             }
  46.         }
  47.     } while (order != 4);
  48.     cout << endl;
  49. }
  50.  
  51. void cups (int small, int medium, int large) {
  52.     cout << "\nCUPS SOLD\n" ;
  53.     cout << setw(10) << "=\n";
  54.     cout << "Number of small cups sold: " << small << "\nNumber of medium cups sold: " << medium << "\nNumber of large cups sold: " << large << endl << endl;
  55. }
  56.  
  57. void coffee (int small, int medium, int large) {
  58.     const int smallvol = 9;
  59.     const int medvol = 12;
  60.     const int largevol = 15;
  61.     int total = smallvol * small + medvol * medium + largevol * large;
  62.     cout << "\nCOFFEE SOLD\n" ;
  63.     cout << setw(12) << "=\n";
  64.     cout << "Total volume of coffee sold: " << total << " oz\n\n";
  65. }
  66.  
  67. void money (int small, int medium, int large) {
  68.     const float smallp = 1.75;
  69.     const float medp = 1.90;
  70.     const float largep = 2.00;
  71.     float total = smallp * small + medp * medium + largep * large;
  72.     cout << "\nMONEY MADE\n" ;
  73.     cout << setw(10) << "=\n";
  74.     cout << fixed << setprecision(2) << "Total amount of money made: $" << total << "\n\n";
  75. }
  76.  
  77. int main () {
  78.     int input, smallamt=0, medamt=0, largeamt=0;
  79.     char use;
  80.     bool end = 0;
  81.     cout << setfill('=') << "Welcome to Jason's Coffee Shop! " << endl;
  82.     cout << "Do you already know how to use the program? (y/n) ";
  83.     do {
  84.         cin >> use;
  85.         if (use == 'y') {
  86.             cout << endl;
  87.         } else if (use == 'n') {
  88.             tutorial();
  89.         } else {
  90.             cout << "That input was not understood, please try again. ";
  91.         }
  92.     } while (use != 'y' && use != 'n');
  93.  
  94.     mainmenu();
  95.     do {
  96.         cin >> input;
  97.         if (input == 1) {
  98.             buy(smallamt,medamt,largeamt);
  99.         } else if (input == 2) {
  100.             cups(smallamt,medamt,largeamt);
  101.         } else if (input == 3) {
  102.             coffee(smallamt, medamt, largeamt);
  103.         } else if (input == 4) {
  104.             money(smallamt, medamt, largeamt);
  105.         } else if (input == 5) {
  106.             cout << endl << setw(50) << "=\n";
  107.             cout << "Thank you for using our program, have a nice day! \n";
  108.             cout << setw(51) << "=\n\n";
  109.             return 0;
  110.         } else {
  111.             cout << "That input was not understood, please try again. ";
  112.         }
  113.     } while (input < 1 || input > 4);
  114. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top