Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // The how-to guide. Called first inside int main()
- void guide()
- {
- cout << "Welcome to Beach Coffee Sells Counter\n\n";
- cout << "======================================================\n\n";
- cout << "How to guide:\nBasically follow the instructions given.\nBut well, here's the full guide\n\n";
- cout << "1. Type in the coffee size that's being ordered\n";
- cout << "2. Type in the amount of coffee that's being ordered\n";
- cout << "3. If there's any other order, type in 1. Otherwise, type in 0\n";
- cout << "4. You can see cups sold, coffee sold, and money earned by typing in 1, 2, or 3.\n";
- cout << "5. You can exit the program by typing in 1 or type 2 to order again (back to order menu)\n\n";
- cout << "======================================================\n\n";
- }
- // Function for choosing size, amount, and cost of each transaction.
- void sellCoffee(int (&arr)[3])
- {
- int arr1[]={0,0,0};
- int n,m,q;
- const float costsmall=1.75, costmed=1.9, costlarge=2;
- float total;
- 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";
- loop:
- cout << "Coffee Size? "; cin >> n;
- if((n==1) || (n==2) || (n==3))
- cout << "";
- else
- {
- cout << "Try again.\n\n";
- goto loop;
- }
- cout << "Amount to order? "; cin >> m;
- switch(n)
- {
- case 1:
- arr1[0]+=m;
- arr[0]+=m;
- break;
- case 2:
- arr1[1]+=m;
- arr[1]+=m;
- break;
- case 3:
- arr1[2]+=m;
- arr[2]+=m;
- break;
- }
- cout << "Is there anything else? (1) No (2) Yes ";
- loop1:
- cin >> q;
- switch(q)
- {
- case 1:
- break;
- case 2:
- goto loop;
- break;
- default:
- goto loop1;
- break;
- }
- total = costsmall*arr1[0] + costmed*arr1[1] + costlarge*arr1[2];
- cout << "That will be $" << total << endl << endl;
- }
- // Function to show each cup size sold
- void displayCupSizeSold(int (&arr)[3])
- {
- cout << endl;
- cout << "Subtotal " << arr[0] << " small size cup(s) sold.\n\n";
- cout << "Subtotal " << arr[1] << " medium size cup(s) sold.\n\n";
- cout << "Subtotal " << arr[2] << " large size cup(s) sold.\n\n";
- }
- // Function to show (in oz) how many coffee sold
- void displayCoffeeSold(int (&arr)[3])
- {
- const int small=9,medium=12,large=15;
- int sum = arr[0]*small + arr[1]*medium + arr[2]*large;
- cout << "Total " << sum << "oz coffee sold.\n\n";
- }
- // Function to show the total earning so far
- void moneyMade(int (&arr)[3],float &mon)
- {
- const float costsmall=1.75, costmed=1.9, costlarge=2;
- mon += arr[0]*costsmall + arr[1]*costmed + arr[2]*costlarge;
- cout << "Money made: $" << mon << "\n\n";
- }
- int main()
- {
- float money;
- int cups[]={0,0,0},x,n;
- loop:
- guide();
- sellCoffee(cups);
- loop1:
- cout << "What do you want to do now? (1) Display cups sold (2) Display coffee sold (3) Show income (4) Other ";
- loop2:
- cin >> n;
- switch(n)
- {
- case 1:
- displayCupSizeSold(cups);
- goto loop1;
- break;
- case 2:
- displayCoffeeSold(cups);
- goto loop1;
- break;
- case 3:
- moneyMade(cups,money);
- goto loop1;
- break;
- case 4:
- cout << endl;
- break;
- default:
- goto loop2;
- break;
- }
- cout << "Do you want to exit the program? (1) Yes (2) No (back to order menu) "; cin >> x;
- switch(x)
- {
- case 1:
- break;
- case 2:
- system ("CLS"); // CLS to clear screen for every transaction
- goto loop;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement