-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrays using average Calculator.txt
58 lines (45 loc) · 1.19 KB
/
Arrays using average 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
Question 2: use the average calculator and use definite loops
one with a while loops
one with a for loop
part 1A
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
//Prompt the user to enter values
while (index < SIZE) then
output "Please enter the student's score:"
input STUDENT_SCORES[index]
//Calculate the total of all scores
total = STUDENT_SCORES[index] + total
index = index + 1
endwhile
//Calculate the average
set average = total / DIVISOR
output "The average of the class is:"
output average
stop
part 1B
start
//Declarations of variables
num STUDENT_SCORES[] = new num[3]
num SIZE = 3
num total = 0
num DIVISOR = 3
num average = 0
//Prompt the user to enter values
for index = 0 to (SIZE - 1) then
output "Please enter the student's score:"
input STUDENT_SCORES[index], index + 1
//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
stop