-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule4SamsCoffeeShop.cpp
More file actions
331 lines (248 loc) · 10.7 KB
/
Copy pathModule4SamsCoffeeShop.cpp
File metadata and controls
331 lines (248 loc) · 10.7 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
//************************************************************************
// Author: Rolando Carreon
// Date: mar 27 2025
// Language: C++
// Assignment: Module 4 Learning Outcome - Sams Coffee Shop Lab
// Description: a menu-driven program that will make the coffee shop
// operationl.
//************************************************************************
#include<iostream>
#include<iomanip> // added for setprecision
using namespace std;
// Global Variables (constants)
double SMALL = 1.75;
double MEDIUM= 1.90;
double LARGE = 2.00;
// function prototypes
void shopHeader();
// displays main menu with choices for cashier
// passes grandTotal, revenue, and cup totals to main
void shopMenu(double& , double&, int& ,int& ,int& , int&);
// display coffee sales and totals for each size and grand total
void sellCoffee(double& ,int& ,int& ,int& , int&);
// display number of cups sold per size and profits
void soldCupsSize(double& ,int& ,int& ,int&);
// display the total number of cups sold
void soldTotal(int&);
// calculate and display 25% revenue of total sales
void profitTotal(double&, double&);
int main()
{
// declare local initilized variables
int smallTotal = 0; // all parameters passed to main by functions called
int mediumTotal = 0;
int largeTotal = 0;
int cupTotal = 0;
double grandTotal = 0.0;
double revenue = 0.0;
// set precision to display by 2 decimal places from here on out
cout << fixed << setprecision(2);
// display main menu that the cashier needs to sell and view sale info
shopMenu(grandTotal, revenue, smallTotal, mediumTotal, largeTotal , cupTotal);
cout << "Successfully Quit the Menu!\n" << endl;
return 0;
}
// function definitions
// header format displayed to organize the cashier user interface
void shopHeader()
{
cout << "****************************************************" << endl;
cout << "\t\t\t\tSam's Coffee Shop" << endl;
cout << "****************************************************" << endl;
}
// main menu of the sam's coffee shop cashier terminal
// a loop to allow the cashier to continue to sell coffee or view sales
// information until they want to quit the program
// saves each sale and cup data to main total profit amount
void shopMenu(double& grandTotal, double& revenue, int& smallTotal,
int& mediumTotal, int& largeTotal, int& cupTotal)
{
int choice; // main menu choices
// cashier chooses to sell coffee or view sales information until they
// enter '5' to quit the program
do {
shopHeader(); // used to organize between seperate choice selections
// display main coffee shop menu
cout << "Please make a selection from the following Menu: " << endl;
cout << "\t 1) Sell a Coffee\n"
<< "\t 2) Show Number of Cups Sold of each Size\n"
<< "\t 3) Show Total Amount of Coffee Sold\n"
<< "\t 4) Show Total Profit\n"
<< "\t 5) Quit Program\n\n";
// prompt cashier to make menu selection
cout << "Selection: ";
cin >> choice;
cout << endl;
switch(choice)
{
case 1: // sell coffee UI
sellCoffee(grandTotal, smallTotal,
mediumTotal, largeTotal , cupTotal);
break;
case 2: // display cups sold per size UI
soldCupsSize(grandTotal, smallTotal,
mediumTotal, largeTotal);
break;
case 3: // display total cups sold UI
soldTotal(cupTotal);
break;
case 4: // display total profit UI
profitTotal(grandTotal, revenue);
break;
case 5: // user selected quit
shopHeader();
cout << "GoodeBye!\n";
break;
default: // invalid input or choice number
cout << "Not a valid choice.\n";
cout << "Choose Again.\n";
break;
} // end switch
} while (choice != 5); // continue untill user selects 5 to quit
}
// a function to sell coffee allowing the cashier to select customer
// coffee size and amount choices in order to display total amount due
// saves each sale and cup data to shopMenu
void sellCoffee(double& grandTotal, int& smallTotal,
int& mediumTotal, int& largeTotal, int& cupTotal)
{
int choice; // sub menu choice
// cup sizes to pick from
int smallCups;
int mediumCups;
int largeCups;
double currentTotal; // total value only for this current Sale
// cashier chooses customer cup size choice and how many cups they want
// displays dollar amount due to pay and repeats menu to continue to
// sell coffee or press '4' to go back to main menu
do {
currentTotal = 0; // reset values after each sale to prevent dupli.
smallCups = 0;
mediumCups = 0;
largeCups = 0;
shopHeader(); // used to organize between seperate Sales
// display coffee sales menu
cout << "Option 1 - Sam's Coffee Shop Menu Choices: " << endl;
cout << "\t1) Small Cup of Coffee - $" << SMALL << "\n"
<< "\t2) Medium Cup of Coffee - $" << MEDIUM << "\n"
<< "\t3) Large Cup of Coffee - $" << LARGE << "\n"
<< "\t4) Go Back to Main Menu" << endl << endl;
// prompt cashier to make menu selection
cout << "Selection: ";
cin >> choice;
cout << endl;
switch(choice)
{
case 1: // small coffee
cout << "How Many Cups of Small Coffee do You Need?: ";
cin >> smallCups;
cout << endl;
currentTotal = smallCups * SMALL; // size x amount saves
smallTotal += smallCups; // increments smalltotal by cups amount
cupTotal += smallCups;
cout << "Customer's Total Amount Due is: $" << currentTotal
<< endl << endl;
break;
case 2: // medium coffee
cout << "How Many Cups of Medium Coffee do You Need?: ";
cin >> mediumCups;
cout << endl;
currentTotal = mediumCups * MEDIUM; // size x amount saves
mediumTotal += mediumCups; // increments total by cups amount
cupTotal += mediumCups;
cout << "Customer's Total Amount Due is: $" << currentTotal
<< endl << endl;
break;
case 3: // large coffee
cout << "How Many Cups of Large Coffee do You Need?: ";
cin >> largeCups;
cout << endl;
currentTotal = largeCups * LARGE; // size x amount saves
largeTotal += largeCups; // increments total by cups amount
cupTotal += largeCups;
cout << "Customer's Total Amount Due is: $" << currentTotal;
cout << endl << endl;
break;
case 4: // user selected quit
break;
default: // invalid input or choice number
cout << "Not a valid choice.\n";
cout << "Choose Again.\n";
break;
} // end switch
grandTotal += currentTotal;
} while (choice != 4 ); // continue untill user selects 4 to quit
}
// displays easy to read coffee shop logistics data containing
// how much of each coffee size sold and the gross profit earned for each
// takes data passed from sellCoffee function and passes data to main
void soldCupsSize(double& grandTotal, int& smallTotal,
int& mediumTotal, int& largeTotal)
{
int choice; // switch menu choice
double smallMoneyTotal; // total money of each size sold
double mediumMoneyTotal;
double largeMoneyTotal;
do {
shopHeader(); // organize format for each new page
cout << "Option 2 - Coffee Logistics Data" << endl << endl;
smallMoneyTotal = smallTotal * SMALL; // calcuate gross profit
// display logisitic info about small coffee cups
cout << "Small Coffee Cups: \n"
<< "\tTotal Cups Sold: " << smallTotal
<< "\n\tGross Total Profit: $" << smallMoneyTotal << endl << endl;
mediumMoneyTotal = mediumTotal * MEDIUM; // calcuate gross profit
// display logisitic info about medium coffee cups
cout << "Medium Coffee Cups: \n"
<< "\tTotal Cups Sold: " << mediumTotal
<< "\n\tGross Total Profit: $" << mediumMoneyTotal << endl << endl;
largeMoneyTotal = largeTotal * LARGE; // calcuate gross profit
// display logisitic info about large coffee cups
cout << "Large Coffee Cups: \n"
<< "\tTotal Cups Sold: " << largeTotal
<< "\n\tGross Total Profit: $" << largeMoneyTotal << endl << endl;
// menu choice
cout << "\t1) Go Back to Main Menu" << endl << endl;
// prompt cashier to make menu selection
cout << "Selection: ";
cin >> choice;
cout << endl;
} while (choice != 1); // repeat until '1' is chosen
}
// displays the total number of cups sold
void soldTotal(int& cupTotal)
{
int choice;
do {
shopHeader(); // organize format for each new page
cout << "Option 3 - Coffee Logistics Data" << endl << endl;
// display logisitic info about coffee cups sold
cout << "Total Amount of Coffee Cups Sold: " << cupTotal
<< endl << endl;
// menu choice
cout << "\t1) Go Back to Main Menu" << endl << endl;
// prompt cashier to make menu selection
cout << "Selection: ";
cin >> choice;
cout << endl;
} while (choice != 1); // repeat until '1' is chosen
}
// calculates and displays 25% of the total sales as revenue
void profitTotal(double& grandTotal, double& revenue)
{
int choice;
do {
shopHeader(); // organize format for each new page
cout << "Option 4 - Coffee Logistics Data" << endl << endl;
revenue = grandTotal * 0.25;
// display logisitic info about revenue from all coffee cups
cout << "Total Calculated Revenue (25%): $" << revenue
<< endl << endl;
// menu choice
cout << "\t1) Go Back to Main Menu" << endl << endl;
// prompt cashier to make menu selection
cout << "Selection: ";
cin >> choice;
cout << endl;
} while (choice != 1); // repeat until '1' is chosen
}