-
Notifications
You must be signed in to change notification settings - Fork 33
/
pizza.cpp
163 lines (124 loc) · 4.73 KB
/
pizza.cpp
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
//*****************************************************************************************************
// Pizza Palace Menu Order System
//
// This program is a simple pizza ordering program that will calculate the total cost of the
// order.
//
//*****************************************************************************************************
#include <iomanip>
#include <iostream>
using namespace std;
//*****************************************************************************************************
int main() {
const double PIZZA = 15.50,
SODA = 2.00,
CHICKEN_NUGGETS = 7.00,
BREADSTICKS = 9.75;
double numItems = 0,
menuItem,
total = 0;
char itemLetter;
cout << "=====================================================\n"
<< "\t\tWelcome to Pizza Palace\n"
<< "=====================================================" << endl;
cout << fixed << setprecision(2) << right;
do {
cout << "-----------------------------------------------------\n\n"
<< "\tA\tPizza" << setw(26) << PIZZA
<< "\n\tB\tSoda" << setw(27) << SODA
<< "\n\tC\tChicken Nuggets" << setw(16) << CHICKEN_NUGGETS
<< "\n\tD\tBreadsticks" << setw(20) << BREADSTICKS
<< "\n\tE\tExit" << endl;
cout << "\nPlease enter the next menu item Letter: ";
cin >> itemLetter;
switch (itemLetter) {
case 'A':
menuItem = PIZZA;
break;
case 'B':
menuItem = SODA;
break;
case 'C':
menuItem = CHICKEN_NUGGETS;
break;
case 'D':
menuItem = BREADSTICKS;
break;
case 'E':
break;
default:
cerr << "\nPlease pick a valid option\n";
}
if (itemLetter == 'A' || itemLetter == 'B' || itemLetter == 'C' || itemLetter == 'D')
numItems++;
cout << "\nNumber of items: " << setprecision(0) << numItems << endl;
if (itemLetter == 'A' || itemLetter == 'B' || itemLetter == 'C' || itemLetter == 'D')
total += menuItem;
cout << "Total: " << setprecision(2) << total << endl;
} while (itemLetter != 'E');
cout << "\nThank you! Enjoy!" << endl;
return 0;
}
//*****************************************************************************************************
/*
=====================================================
Welcome to Pizza Palace
=====================================================
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: A
Number of items: 1
Total: 15.50
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: S
Please pick a valid option
Number of items: 1
Total: 15.50
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: d
Please pick a valid option
Number of items: 1
Total: 15.50
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: D
Number of items: 2
Total: 25.25
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: C
Number of items: 3
Total: 32.25
-----------------------------------------------------
A Pizza 15.50
B Soda 2.00
C Chicken Nuggets 7.00
D Breadsticks 9.75
E Exit
Please enter the next menu item Letter: E
Number of items: 3
Total: 32.25
Thank you! Enjoy!
*/