-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumberOperations.html
426 lines (402 loc) · 27 KB
/
NumberOperations.html
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<!DOCTYPE html>
<html lang="en">
<head>
<title>Alexander S. Corey</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-sm bg-info navbar-dark justify-content-center sticky-top">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="bio.html">About me</a>
</li>
<li class="nav-item">
<a class="nav-link" href="static/ACoreyResume.pdf">Resume</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/acoreynews">Github</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://linkedin.com/in/alexander-s-corey">Linkedin</a>
</li>
</ul>
</nav>
<!-- HTML generated using hilite.me --><div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><table><tr><td><pre style="margin: 0; line-height: 125%"> 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</pre></td><td><pre style="margin: 0; line-height: 125%"><span style="color: #888888">/// @author Alexander Corey</span>
<span style="color: #888888">/// @attention I pledge my word of honor that I have abided by the CSN</span>
<span style="color: #888888">/// Academic Integrity Policy while completing this assignment.</span>
<span style="color: #888888">/// @file pa04.cpp</span>
<span style="color: #888888">/// @date 2017-10-01</span>
<span style="color: #888888">/// @brief This program prompts the user to enter five numbers and then</span>
<span style="color: #888888">/// presents them with a menu of number operations to choose from.</span>
<span style="color: #888888">/// @note I spent approximately 4 to 5 hours developing this program.</span>
<span style="color: #888888">/// I used the clear and ignore functions to restore the program back</span>
<span style="color: #888888">/// to working order in the likely event that the user put it into a</span>
<span style="color: #888888">/// fail state. I used Xcode for the majority of the program's</span>
<span style="color: #888888">/// development which sped up the debugging process.</span>
<span style="color: #557799">#include <iostream></span>
<span style="color: #557799">#include <string></span>
<span style="color: #008800; font-weight: bold">using</span> <span style="color: #008800; font-weight: bold">namespace</span> std;
<span style="color: #333399; font-weight: bold">int</span> <span style="color: #0066BB; font-weight: bold">main</span>()
{
<span style="color: #888888">// Local Const variables</span>
<span style="color: #008800; font-weight: bold">const</span> string SM_CHOICE <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Smallest value"</span>; <span style="color: #888888">// smallest value text</span>
<span style="color: #008800; font-weight: bold">const</span> string LG_CHOICE <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Largest value"</span>; <span style="color: #888888">// largest value text</span>
<span style="color: #008800; font-weight: bold">const</span> string SUM_CHOICE <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Sum of values"</span>; <span style="color: #888888">// sum of values text</span>
<span style="color: #008800; font-weight: bold">const</span> string AVG_CHOICE <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Average of values"</span>; <span style="color: #888888">// avg of values text</span>
<span style="color: #008800; font-weight: bold">const</span> string CHOICE_A <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"a."</span>; <span style="color: #888888">// choice a menu string</span>
<span style="color: #008800; font-weight: bold">const</span> string CHOICE_B <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"b."</span>; <span style="color: #888888">// choice b menu string</span>
<span style="color: #008800; font-weight: bold">const</span> string CHOICE_C <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"c."</span>; <span style="color: #888888">// choice c menu string</span>
<span style="color: #008800; font-weight: bold">const</span> string CHOICE_D <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"d."</span>; <span style="color: #888888">// choice d menu string</span>
<span style="color: #008800; font-weight: bold">const</span> string OPENING_PROMPT <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Please enter five numbers, separated by"</span>
<span style="background-color: #fff0f0">" spaces"</span>; <span style="color: #888888">// opening prompt text</span>
<span style="color: #008800; font-weight: bold">const</span> string MENU_PROMPT <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"Please enter the letter of the choice you"</span>
<span style="background-color: #fff0f0">" desire"</span>; <span style="color: #888888">// menu prompt text</span>
<span style="color: #008800; font-weight: bold">const</span> string RETRY_PROMPT <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"It doesn't look like anything to me."</span>
<span style="background-color: #fff0f0">" Please try again."</span>; <span style="color: #888888">// text that prompts user to run program again</span>
<span style="color: #008800; font-weight: bold">const</span> string ERROR_MESSAGE <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"It doesn't look like anything to me."</span>
<span style="background-color: #fff0f0">" Please restart the program."</span>; <span style="color: #888888">// text for error message</span>
<span style="color: #008800; font-weight: bold">const</span> string SM_VALUE_IS <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"The smallest value is "</span>; <span style="color: #888888">// text for</span>
<span style="color: #888888">// smallest value calculation message printed for user</span>
<span style="color: #008800; font-weight: bold">const</span> string LG_VALUE_IS <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"The largest value is "</span>; <span style="color: #888888">// text for</span>
<span style="color: #888888">//largest value calculation message printed for user</span>
<span style="color: #008800; font-weight: bold">const</span> string SUM_IS <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"The sum of values is "</span>; <span style="color: #888888">// text for</span>
<span style="color: #888888">// sum of values calculation message printed for user</span>
<span style="color: #008800; font-weight: bold">const</span> string AVG_IS <span style="color: #333333">=</span> <span style="background-color: #fff0f0">"The average of values is "</span>; <span style="color: #888888">// text for</span>
<span style="color: #888888">// average of values value calculation message printed for user</span>
<span style="color: #008800; font-weight: bold">const</span> <span style="color: #333399; font-weight: bold">char</span> period <span style="color: #333333">=</span> <span style="color: #0044DD">'.'</span>; <span style="color: #888888">// period character for misc uses</span>
<span style="color: #008800; font-weight: bold">const</span> <span style="color: #333399; font-weight: bold">char</span> space <span style="color: #333333">=</span> <span style="color: #0044DD">' '</span>; <span style="color: #888888">// space character for misc uses</span>
<span style="color: #888888">// Local variables</span>
<span style="color: #333399; font-weight: bold">double</span> userInput1 <span style="color: #333333">=</span> <span style="color: #6600EE; font-weight: bold">0.0</span>; <span style="color: #888888">// holds first value input by user</span>
<span style="color: #333399; font-weight: bold">double</span> userInput2 <span style="color: #333333">=</span> <span style="color: #6600EE; font-weight: bold">0.0</span>; <span style="color: #888888">// holds second value input by user</span>
<span style="color: #333399; font-weight: bold">double</span> userInput3 <span style="color: #333333">=</span> <span style="color: #6600EE; font-weight: bold">0.0</span>; <span style="color: #888888">// holds third value input by user</span>
<span style="color: #333399; font-weight: bold">double</span> userInput4 <span style="color: #333333">=</span> <span style="color: #6600EE; font-weight: bold">0.0</span>; <span style="color: #888888">// holds fourth value input by user</span>
<span style="color: #333399; font-weight: bold">double</span> userInput5 <span style="color: #333333">=</span> <span style="color: #6600EE; font-weight: bold">0.0</span>; <span style="color: #888888">// holds fifth value input by user</span>
<span style="color: #333399; font-weight: bold">double</span> smallestValue; <span style="color: #888888">// holds smallest value calculation</span>
<span style="color: #333399; font-weight: bold">double</span> largestValue; <span style="color: #888888">// holds largest value calculation</span>
<span style="color: #333399; font-weight: bold">double</span> sumValues; <span style="color: #888888">// holds sum of values calculation</span>
<span style="color: #333399; font-weight: bold">double</span> avgValues; <span style="color: #888888">// holds average of values calculation</span>
<span style="color: #333399; font-weight: bold">char</span> menuChoice <span style="color: #333333">=</span> <span style="color: #0000DD; font-weight: bold">0</span>; <span style="color: #888888">// holds menu choice input by user</span>
<span style="color: #888888">// INPUT</span>
cout <span style="color: #333333"><<</span> OPENING_PROMPT <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cin <span style="color: #333333">>></span> userInput1 <span style="color: #333333">>></span>userInput2 <span style="color: #333333">>></span> userInput3 <span style="color: #333333">>></span> userInput4
<span style="color: #333333">>></span> userInput5;
<span style="color: #888888">// Checks input failure</span>
<span style="color: #008800; font-weight: bold">if</span> (<span style="color: #333333">!</span>cin)
{
<span style="color: #888888">// Restores program to working state if user input is invalid</span>
cin.clear();
cin.ignore(<span style="color: #0000DD; font-weight: bold">200</span>, <span style="color: #0044DD">'\n'</span>);
cout <span style="color: #333333"><<</span> RETRY_PROMPT <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> OPENING_PROMPT <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cin <span style="color: #333333">>></span> userInput1 <span style="color: #333333">>></span>userInput2 <span style="color: #333333">>></span> userInput3 <span style="color: #333333">>></span> userInput4
<span style="color: #333333">>></span> userInput5;
<span style="color: #008800; font-weight: bold">if</span> (<span style="color: #333333">!</span>cin)
cout <span style="color: #333333"><<</span> ERROR_MESSAGE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
<span style="color: #008800; font-weight: bold">else</span> {
cout <span style="color: #333333"><<</span> MENU_PROMPT <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_A <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> SM_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_B <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> LG_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_C <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> SUM_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_D <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> AVG_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cin <span style="color: #333333">>></span> menuChoice;
}
}
<span style="color: #008800; font-weight: bold">else</span>
{
cout <span style="color: #333333"><<</span> MENU_PROMPT <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_A <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> SM_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_B <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> LG_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_C <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> SUM_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cout <span style="color: #333333"><<</span> CHOICE_D <span style="color: #333333"><<</span> space <span style="color: #333333"><<</span> AVG_CHOICE <span style="color: #333333"><<</span> <span style="background-color: #fff0f0">"</span><span style="color: #666666; font-weight: bold; background-color: #fff0f0">\n</span><span style="background-color: #fff0f0">"</span>;
cin <span style="color: #333333">>></span> menuChoice;
}
<span style="color: #888888">// SWITCH - PROCESS AND OUTPUT</span>
<span style="color: #888888">// menu choice A/a logic</span>
<span style="color: #008800; font-weight: bold">switch</span> (menuChoice) {
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'A'</span>:
smallestValue <span style="color: #333333">=</span> userInput1;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput2)
smallestValue <span style="color: #333333">=</span> userInput2;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput3)
smallestValue <span style="color: #333333">=</span> userInput3;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput4)
smallestValue <span style="color: #333333">=</span> userInput4;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput5)
smallestValue <span style="color: #333333">=</span> userInput5;
cout <span style="color: #333333"><<</span> SM_VALUE_IS <span style="color: #333333"><<</span> smallestValue <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'a'</span>:
smallestValue <span style="color: #333333">=</span> userInput1;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput2)
smallestValue <span style="color: #333333">=</span> userInput2;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput3)
smallestValue <span style="color: #333333">=</span> userInput3;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput4)
smallestValue <span style="color: #333333">=</span> userInput4;
<span style="color: #008800; font-weight: bold">if</span> (smallestValue <span style="color: #333333">>=</span> userInput5)
smallestValue <span style="color: #333333">=</span> userInput5;
cout <span style="color: #333333"><<</span> SM_VALUE_IS <span style="color: #333333"><<</span> smallestValue <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #888888">// menu choice B/b logic</span>
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'B'</span>:
largestValue <span style="color: #333333">=</span> userInput1;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput2)
largestValue <span style="color: #333333">=</span> userInput2;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput3)
largestValue <span style="color: #333333">=</span> userInput3;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput4)
largestValue <span style="color: #333333">=</span> userInput4;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput5)
largestValue <span style="color: #333333">=</span> userInput5;
cout <span style="color: #333333"><<</span> LG_VALUE_IS <span style="color: #333333"><<</span> largestValue <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'b'</span>:
largestValue <span style="color: #333333">=</span> userInput1;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput2)
largestValue <span style="color: #333333">=</span> userInput2;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput3)
largestValue <span style="color: #333333">=</span> userInput3;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput4)
largestValue <span style="color: #333333">=</span> userInput4;
<span style="color: #008800; font-weight: bold">if</span> (largestValue <span style="color: #333333"><=</span> userInput5)
largestValue <span style="color: #333333">=</span> userInput5;
cout <span style="color: #333333"><<</span> LG_VALUE_IS <span style="color: #333333"><<</span> largestValue <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #888888">// menu choice C/c logic</span>
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'C'</span>:
sumValues <span style="color: #333333">=</span> userInput1 <span style="color: #333333">+</span> userInput2 <span style="color: #333333">+</span> userInput3 <span style="color: #333333">+</span> userInput4
<span style="color: #333333">+</span> userInput5;
cout <span style="color: #333333"><<</span> SUM_IS <span style="color: #333333"><<</span> sumValues <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'c'</span>:
sumValues <span style="color: #333333">=</span> userInput1 <span style="color: #333333">+</span> userInput2 <span style="color: #333333">+</span> userInput3 <span style="color: #333333">+</span> userInput4
<span style="color: #333333">+</span> userInput5;
cout <span style="color: #333333"><<</span> SUM_IS <span style="color: #333333"><<</span> sumValues <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'d'</span>:
sumValues <span style="color: #333333">=</span> userInput1 <span style="color: #333333">+</span> userInput2 <span style="color: #333333">+</span> userInput3 <span style="color: #333333">+</span> userInput4
<span style="color: #333333">+</span> userInput5;
avgValues <span style="color: #333333">=</span> sumValues<span style="color: #333333">/</span><span style="color: #0000DD; font-weight: bold">5</span>;
cout <span style="color: #333333"><<</span> AVG_IS <span style="color: #333333"><<</span> avgValues <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #888888">// menu choice D/d logic</span>
<span style="color: #008800; font-weight: bold">case</span> <span style="color: #0044DD">'D'</span>:
sumValues <span style="color: #333333">=</span> userInput1 <span style="color: #333333">+</span> userInput2 <span style="color: #333333">+</span> userInput3 <span style="color: #333333">+</span> userInput4
<span style="color: #333333">+</span> userInput5;
avgValues <span style="color: #333333">=</span> sumValues<span style="color: #333333">/</span><span style="color: #0000DD; font-weight: bold">5</span>;
cout <span style="color: #333333"><<</span> AVG_IS <span style="color: #333333"><<</span> avgValues <span style="color: #333333"><<</span> period;
<span style="color: #008800; font-weight: bold">break</span>;
<span style="color: #888888">// default menu choice</span>
<span style="color: #997700; font-weight: bold">default:</span>
<span style="color: #008800; font-weight: bold">if</span> (cin) {
cout <span style="color: #333333"><<</span> ERROR_MESSAGE;
<span style="color: #008800; font-weight: bold">break</span>;
}
}
cout <span style="color: #333333"><<</span> endl;
<span style="color: #008800; font-weight: bold">return</span> <span style="color: #0000DD; font-weight: bold">0</span>;
}
</pre></td></tr></table></div>
</body>
</html>