1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#include <iostream>
#include <iomanip>
using namespace std;
const double small_Cup = 1.75, med_Cup = 1.90, large_Cup = 2.00;
int mainMenu()
// function for the main menu in which the user chooses what they want to do or view.
{
int ret = 0;
cout << "You may return to this prompt at any time by pressing #." << endl;
cout << "What would you like to do? Select the desired number." << endl;
cout << "1. Purchase coffee." << endl;
cout << "2. View how many cups of coffee of each size has been sold." << endl;
cout << "3. View the total amount of cups of coffee sold." << endl;
cout << "4. View how much money is due." << endl;
cout << "5. End." << endl;
cin >> ret;
return ret;
}
int productMenu(int small, int medium, int large)
// function to view the sizes of cups and the cost of each one. the user may then make a selection.
{
int smallCount = 0;
int medCount = 0;
int largeCount = 0;
cout << "Read over the menu and enter the number of each product you would like." << endl;
cout << "Small(9oz.)................. $ " << showpoint << setprecision(3) << small_Cup << endl;
cout << "Medium(12oz.)................ $ " << showpoint << setprecision(3) << med_Cup << endl;
cout << "Large(15oz.)................. $ " << showpoint << setprecision(3) << large_Cup << endl;
cout << "How many small cups of coffee would you like? ";
cin >> small;
cout << endl;
cout << "How many medium cups of coffee would you like? ";
cin >> medium;
cout << endl;
cout << "How many large cups of coffee would you like? ";
cin >> large;
cout << endl;
}
void amountDue(int small, int medium, int large)
//function to get the total amount due for all sizes.
{
double amount;
amount = (small_Cup * small) + (medium * med_Cup) + (large * large_Cup);
cin >> amount;
cout << "The total amound due is: " << showpoint << amount << endl;
}
void eachCup(int small, int medium, int large)
// function to view the total of each cup sold.
{
cout << "The total amount of Small Oz. cups sold is: " << small << "." << endl;
cout << "The total amount of Medium Oz. cups sold is: " << medium << "." << endl;
cout << "The total amount of Large Oz. cups sold is: " << large << "." << endl;
}
void totalCups(int small, int medium, int large)
//function to view how many cups of coffee has been sold in all.
{
double allCups;
allCups = small + medium + large;
cout << "The total amount of cups of coffee sold is: " << allCups << endl;
}
int main()
//main combines all of the functions to output the user's selected choice.
{
int small = 0;
int medium = 0;
int large = 0;
int selection = 0;
selection = mainMenu();
do {
switch (selection)
{
case 1:
(productMenu(small, medium, large));
break;
case 2:
eachCup(small, medium, large);
break;
case 3:
totalCups(small, medium, large);
break;
case 4:
amountDue(small, medium, large);
break;
}
} while (selection = mainMenu());
}
|