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.
21; 22; 23 2023
© The Independent Institute of Education (Pty) Ltd 2023
Page 4 of 6
• Create a module called “Low” which does the following:
o Display the name of the learner with the lowest mark.
Place comments in your pseudocode and use descriptive and appropriate messages/labels for the output.
The report must display the following:
CLASS REPORT
NAME MARK ACHIEVED CATEGORY
Joe 68 Pass
Mpho 56 Pass
Kyle 43 Fail
Susan 49 Fail
Thando 76 Distinction
Refilwe 80 Distinction
John 50 Pass
Katlego 75 Distinction
Joyce 63 Pass
Sisanda 44 Fail
AVERAGE CLASS MARK: 60.4 %
HIGHEST MARK: Refilwe
LOWEST MARK: Kyle

MODULE Main:

DECLARE Names as an array of strings with size 10
DECLARE Marks as an array of integers with size 10

DISPLAY "Please input the names and marks for the class:"

FOR i = 1 to 10 DO:
DISPLAY "Name " + i + ":"
INPUT Names[i]
VALIDATE Names[i] is not empty and is a string
DISPLAY "Mark " + i + ":"
INPUT Marks[i]
WHILE Marks[i] < 0 OR Marks[i] > 100 DO:
DISPLAY "Invalid mark input. Please input a mark between 0 and 100:"
INPUT Marks[i]
END WHILE
END FOR

DISPLAY "CLASS REPORT"
DISPLAY "NAME\tMARK ACHIEVED\tCATEGORY"

FOR i = 1 to 10 DO:
DISPLAY Names[i] + "\t" + Marks[i] + "\t" + CALCULATE_CATEGORY(Marks[i])
END FOR

DISPLAY "AVERAGE CLASS MARK: " + CALCULATE_AVERAGE(Marks) + "%"

HIGH(Names, Marks)
LOW(Names, Marks)

END MODULE

MODULE CALCULATE_CATEGORY(mark):

IF mark >= 75 THEN:
RETURN "Distinction"
ELSE IF mark < 50 THEN:
RETURN "Fail"
ELSE:
RETURN "Pass"
END IF

END MODULE

MODULE CALCULATE_AVERAGE(marks):

DECLARE sum as integer
DECLARE average as float

FOR i = 1 to 10 DO:
sum = sum + marks[i]
END FOR

average = sum / 10.0

RETURN average

END MODULE

MODULE HIGH(names, marks):

DECLARE highest as integer
DECLARE high_name as string

highest = marks[1]

FOR i = 2 to 10 DO:
IF marks[i] > highest THEN:
highest = marks[i]
high_name = names[i]
END IF
END FOR

DISPLAY "HIGHEST MARK: " + high_name

END MODULE

MODULE LOW(names, marks):

DECLARE lowest as integer
DECLARE low_name as string

lowest = marks[1]

FOR i = 2 to 10 DO:
IF marks[i] < lowest THEN:
lowest = marks[i]
low_name = names[i]
END IF
END FOR

DISPLAY "LOWEST MARK: " + low_name

END MODULE

Declare and initialize two arrays:

- names (string) with size 10
- marks (numeric) with size 10
Declare and initialize variables:
- totalMarks = 0
- highestMark = 0
- lowestMark = 100

FOR i = 0 to 9
Display "Enter name of learner number ", i+1
Read names[i]
Display "Enter mark for learner ", names[i]
Read marks[i]

WHILE marks[i] is not between 0 and 100
Display "Invalid mark. Enter mark for learner ", names[i]
Read marks[i]

totalMarks = totalMarks + marks[i]

IF marks[i] is greater than highestMark
highestMark = marks[i]
highestIndex = i

IF marks[i] is less than lowestMark
lowestMark = marks[i]
lowestIndex = i

IF marks[i] is greater than or equal to 75
category = "Distinction"
ELSE IF marks[i] is less than 50
category = "Fail"
ELSE
category = "Pass"

Display names[i], marks[i], category

averageMark = totalMarks / 10
Display "AVERAGE CLASS MARK: ", averageMark, "%"
Display "HIGHEST MARK: ", names[highestIndex]
Display "LOWEST MARK: ", names[lowestIndex]