Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <limits>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- void showMenu(); //a function to show the user how to use the program
- void sellCoffee(int quantity, char size, double totalPrice, double smallPrice, double medPrice, double largePrice, int& totalCupsSmall, int& totalCupsMed, int& totalCupsLargem, double& grandTotal); //a function to sell coffee -- Buy coffee in any size and in any number of cups.
- void showCoffeeStats(int& totalCupsSmall, int& totalCupsMed, int& totalCupsLarge); //a function to show the number of cups of each size sold -- avaliable at any time.
- void showTotalCoffee(int& totalCupsSmall, int& totalCupsMed, int& totalCupsLarge, int& allSizeTotal); //a function to show the total amount of coffee sold -- avaliable at any time.
- void showTotalMoney(double& grandTotal); //and a function to show the total money made. -- avaliable at any time.
- void exitProgram();
- int main()
- {
- int selection = 0;
- char size;
- int quantity = 0;
- double totalPrice = 0;
- //int smallOz=9;
- //int medOz=12;
- //int largeOz=15;
- double smallPrice = 1.75;
- double medPrice = 1.90;
- double largePrice = 2.00;
- int totalCupsSmall = 0;
- int totalCupsMed = 0;
- int totalCupsLarge = 0;
- double grandTotal = 0;
- int allSizeTotal =0;
- showMenu();
- while (true) {
- cout<<endl;
- cout << "\nPlease enter your selection: ";
- cin >> selection;
- if (selection == 1) {
- sellCoffee(quantity, size, totalPrice, smallPrice, medPrice, largePrice, totalCupsSmall, totalCupsMed, totalCupsLarge, grandTotal);
- }
- else if (selection == 2) {
- showCoffeeStats(totalCupsSmall, totalCupsMed, totalCupsLarge);
- }
- else if (selection == 3) {
- showTotalCoffee(totalCupsSmall, totalCupsMed, totalCupsLarge, allSizeTotal);
- }
- else if (selection == 4) {
- showTotalMoney(grandTotal);
- }
- else if (selection == 5) {
- exitProgram();
- }
- }
- return 0;
- }
- void showMenu()
- {
- cout << "************Welcome to the Coffee Shop!************";
- cout << "\n ****MENU**** ";
- cout << "\n Small Coffee - $1.75 ";
- cout << "\n Medium Coffee - $1.90 ";
- cout << "\n Large Coffee - $2.00 ";
- cout << "\n Press '1' to order your own coffee! ";
- cout << "\n Press '2' to see the total cups sold! ";
- cout << "\n Press '3' to see the total coffee sold! ";
- cout << "\n Press '4' to see the total money earned! ";
- cout << "\n Press '5' to exit the program! ";
- cout << "\n*************************************************";
- cout << endl;
- };
- void sellCoffee(int quantity, char size, double totalPrice, double smallPrice, double medPrice, double largePrice, int& totalCupsSmall, int& totalCupsMed, int& totalCupsLarge, double& grandTotal)
- {
- cout << "\nWhat size coffee would you like to purchase?(S=Small / M=Med / L=Large): ";
- cin >> size;
- cout << "\nHow many coffee would you like to order?: " << quantity;
- cin >> quantity;
- cout << "\nWould you like to order another size of coffee?: ";
- if (size == 'S' || size == 's') {
- totalPrice = (quantity * smallPrice);
- totalCupsSmall += quantity;
- }
- else if (size == 'M' || size == 'm') {
- totalPrice = (quantity * medPrice);
- totalCupsMed += quantity;
- }
- else if (size == 'L' || size == 'l') {
- totalPrice = (quantity * largePrice);
- totalCupsLarge += quantity;
- }
- grandTotal += totalPrice;
- cout << "\nAwesome, thank you! These are your order details!: ";
- cout << fixed << showpoint << setprecision(2);
- cout << "\n Number of cups ordered: " << quantity;
- cout << "\n Size of coffee ordered: " << size;
- cout << "\n Total Price of order: $" << totalPrice;
- };
- void showCoffeeStats(int& totalCupsSmall, int& totalCupsMed, int& totalCupsLarge)
- {
- cout << "\nHere are the total stats for each size of coffee sold: ";
- cout << "\nLarge Coffee: " <<totalCupsLarge;
- cout << "\nMedium Coffee: " <<totalCupsMed;
- cout << "\nSmall Coffee: " <<totalCupsSmall;
- };
- void showTotalMoney(double& grandTotal)
- {
- cout << fixed << showpoint << setprecision(2);
- cout << "\nTotal Money Earned: $" << grandTotal;
- };
- void showTotalCoffee(int& totalCupsSmall, int& totalCupsMed, int& totalCupsLarge, int& allSizeTotal)
- {
- allSizeTotal = (totalCupsLarge + totalCupsMed + totalCupsSmall);
- cout << "\nHere is the total number of coffee cups sold (all sizes): " << allSizeTotal;
- };
- void exitProgram()
- {
- exit(0);
- };
Advertisement
Add Comment
Please, Sign In to add comment