-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudcode for 10 learners marks with arrays and methods .txt
131 lines (71 loc) · 3.01 KB
/
pseudcode for 10 learners marks with arrays and methods .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
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
question
Write the pseudocode for the scenario below.
A teacher has a class of 10 learners who recently wrote a test. The teacher would like to store both the
learner’s name and their test mark in an array. However, this is not possible because their names are in
string format and their marks are numeric. Different data types cannot be stored in one array. This means
that you need to have two parallel arrays. One array will store the learner’s names and the corresponding
elements in the other array will be their marks. Verify that the marks input are between 0 and 100. Any
mark input outside of this range, the user must input the mark until it is within the range.
start
Declarations
num count
string [] names = { Joe, Mpho, Kyle, Susan, Thando, Refilwe, John, Katlego, Joyce, Sisanda}
num [] testMarks = { 68, 56, 43, 49, 76, 80, 50, 75, 63, 44}
string [] userNames = new userNames [10]
num [] userMarks = new userMarks [10]
num totalAttempts = 15
set count = 0
while (count < 15)
output "what is the learners name"
userNames = Readline()
count ++
totalAttempts = totalAttempts - 1
if (userNames = names.Length)
output "what is the learners mark, the mark must be between 0 to 100"
userMarks = Connvert.ToInt32(ReadLine)
if (userMarks != testMarks.Length)
output " that is not the learners mark, please try again "
else
output "that is a valid mark"
else
output "that learner is not in the database, you have a total of:" + count
endif
if (userMarks < 100)
output "the number is valid"
else
output "that number is invalid, you have " + count " attempts left before the program closes"
endif
endwhile
// call method
CalculateAverageMark(testMarks)
// call method
High(testMarks)
//call method
DisplayInformation(userMarks, userNames)
output " the highest mark was " + highestMark + " scored by Refilwe"
stop
void DisplayInformation(userMarks, userNames)
Declarations
num count
set count = 0
while (count < 10)
if (userMarks >= 75)
output "learner name:" + userNames + "distinction "
else if (usermarks < 50)
output "learners:" + userNames + " got" + userMarks " failed
else
output "learners:" + userNames + " got a total of:" + userMarks + " therefore they passed"
endif
endif
return
CalculateAverageMark(userMarks)
Declarations
num average
userMarks += userMarks[10]
average = (usermarks / 10) * 100
return average
High(testMarks)
highestMark = 80
highestMarkLearner = Refilwe
output " the highest mark was:" + highestMark + " this was scored by:" + highestMarkLearner
return