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.
The values below are an example of the names and marks in the array for this scenario and explanation.
Use the values that the teacher will input and not those below.
Example Data
Names - string Marks - numeric
Joe 68
Mpho 56
Kyle 43
Susan 49
Thando 76
Refilwe 80
John 50
Katlego 75
Joyce 63
Sisanda 44
You are required to do the following for the teacher:
• Display the entire class’ names with their corresponding mark and result category.
o Any learner with a mark equal to or above 75 display “Distinction” next to their mark.
o For those learners with a mark less than 50, display “Fail”.
o All the other students must have the word “Pass” next to their mark.
• Calculate and display the average class mark.
• Create a module called “High” which does the following:
o Display the name of the learner with the highest mark.
1 answer
DECLARE names[10] AS string // array to store learner names
DECLARE marks[10] AS numeric // array to store learner marks
DECLARE i as integer // variable to use as iterator
FOR i = 0 to 9
DISPLAY "Enter name for learner ", i+1
READ names[i]
WHILE marks[i] is not between 0 and 100
DISPLAY "Enter marks for learner ", i+1
READ marks[i]
END WHILE
END FOR
// display class' names, marks, and result category
FOR i = 0 to 9
DISPLAY names[i], " ", marks[i]
IF marks[i] >= 75
DISPLAY " Distinction"
ELSE IF marks[i] < 50
DISPLAY " Fail"
ELSE
DISPLAY " Pass"
END IF
END FOR
// calculate and display average class mark
DECLARE average as numeric
DECLARE total as numeric
FOR i = 0 to 9
total = total + marks[i]
END FOR
average = total / 10
DISPLAY "Average class mark: ", average
// module to display learner with highest mark
MODULE High
DECLARE highestMark as numeric
DECLARE highestName as string
highestMark = marks[0]
highestName = names[0]
FOR i = 1 to 9
IF marks[i] > highestMark
highestMark = marks[i]
highestName = names[i]
END IF
END FOR
DISPLAY "Learner with highest mark: ", highestName, " (", highestMark, ")"
END MODULE
END