-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSentnel and Priming input for Calculator.txt
89 lines (68 loc) · 1.99 KB
/
Sentnel and Priming input for Calculator.txt
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
Question 2: modify the average calculator into indefinite loops
one with setinel values
one with priming input
part 1C
start
//Declarations of variables
num STUDENT_SCORES[] = new num[3]
num index = 0
num SIZE = 3
num total = 0
num DIVISOR = 3
num average = 0
num QUIT = "XXX"
string userChoice
//Prompt the user to enter values
if (userChoice <> QUIT ) then
do
for index = 0 to (SIZE - 1) step 1
output "Please enter the student's score:"
input STUDENT_SCORES[index], index++
//Calculate the total of all scores
total = STUDENT_SCORES[index] + total
endfor
//Calculate the average
set average = total / DIVISOR
output "The average of the class is:"
output average
//Reprompt user to choose to continue
output "Do you wish to continue entering another set of score, type XXX if no:"
input userChoice
while (index < SIZE) then
else
output "Thank you for your answer, Goodbye."
endif
stop
part 1D
start
//Declarations of variables
num STUDENT_SCORES[] = new num[3]
num index = 0
num SIZE = 3
num total = 0
num DIVISOR = 3
num average = 0
string userChoice
//Prompt user to start the program or not
output "Do you wish to start the program, type YES or NO if: "
input userChoice
//Prompt the user to enter values
while (userChoice == "YES") then
for index = 0 to (SIZE - 1) step 1
output "Please enter the student's score:"
input STUDENT_SCORES[index], index++
//Calculate the total of all scores
total = STUDENT_SCORES[index] + total
endfor
//calculate the average
set average = total / DIVISOR
output "The average of the class is:"
output average
//Reprompt user to choose to continue
output "Do you wish to continue entering another set of score, type YES or NO:"
input userChoice
endwhile
if (userChoice == "NO") then
output "Thank you for your answer, Goodbye."
endif
stop