The 15-mark scenario
The last question on Paper 2
- The final question on Paper 2 is worth about 15 marks. It describes a scenario and asks for a whole program.
- It usually gives parallel arrays: a 1-D array of names and a 2-D array of numbers, where the same index means the same person.
- The marks come from a list of small, separate points: a loop over every person, a reset, a total, an average, a decision, a count, an output. Every point you write earns marks, even if another part is wrong.

Plan before you write
Example task: For each student, find the total and the average (rounded to a whole number) of the three test marks. Give a grade: Distinction for 70 or more, Merit for 55 or more, Pass for 40 or more, otherwise Fail. Output each name with the total, average and grade, then how many students got each grade.
- Name the data the question gives:
StudentName[1:4],StudentMark[1:4, 1:3]. - List your own variables with a type:
Total,Average,Grade, and one counter for each grade. - Before the loops: set every counter to 0.
- Outer loop over the students. Inside it, set
Totalto 0, then an inner loop over the tests. - After the inner loop: the average, the grade decision and the count, then the output line for that student.
- After the outer loop: output the counts.
CONSTANT ClassSize ← 4
CONSTANT Tests ← 3
DECLARE StudentName : ARRAY[1:4] OF STRING
DECLARE StudentMark : ARRAY[1:4, 1:3] OF INTEGER
DECLARE Student, Test, Total, Average : INTEGER
DECLARE Grade : STRING
DECLARE Distinctions, Merits, Passes, Fails : INTEGER
StudentName[1] ← "Ava"
StudentName[2] ← "Ben"
StudentName[3] ← "Cai"
StudentName[4] ← "Dee"
StudentMark[1, 1] ← 81
StudentMark[1, 2] ← 74
StudentMark[1, 3] ← 69
StudentMark[2, 1] ← 52
StudentMark[2, 2] ← 61
StudentMark[2, 3] ← 58
StudentMark[3, 1] ← 35
StudentMark[3, 2] ← 48
StudentMark[3, 3] ← 41
StudentMark[4, 1] ← 30
StudentMark[4, 2] ← 22
StudentMark[4, 3] ← 39
Distinctions ← 0
Merits ← 0
Passes ← 0
Fails ← 0
FOR Student ← 1 TO ClassSize
Total ← 0
FOR Test ← 1 TO Tests
Total ← Total + StudentMark[Student, Test]
NEXT Test
Average ← ROUND(Total / Tests, 0)
IF Average >= 70
THEN
Grade ← "Distinction"
Distinctions ← Distinctions + 1
ELSE
IF Average >= 55
THEN
Grade ← "Merit"
Merits ← Merits + 1
ELSE
IF Average >= 40
THEN
Grade ← "Pass"
Passes ← Passes + 1
ELSE
Grade ← "Fail"
Fails ← Fails + 1
ENDIF
ENDIF
ENDIF
OUTPUT StudentName[Student], " ", Total, " ", Average, " ", Grade
NEXT Student
OUTPUT "Distinction: ", Distinctions, " Merit: ", Merits, " Pass: ", Passes, " Fail: ", Fails
- The output starts
Ava 224 75 Distinctionand ends with one count of each grade. - In the exam the arrays are already filled: leave out the assignment lines and start at the counters.
Where the marks are
| Mark point | In the program |
|---|---|
| constants or clear limits for the loops | CONSTANT ClassSize ← 4 |
| counters set to 0 before the loops | Distinctions ← 0 |
| outer loop over every student | FOR Student ← 1 TO ClassSize |
| total reset inside the outer loop | Total ← 0 |
| inner loop adds the marks, with the right indexes | StudentMark[Student, Test] |
| average rounded as asked | ROUND(Total / Tests, 0) |
| grades tested from the top boundary down | >= 70, then >= 55, then >= 40 |
| each counter increased in its branch | Merits ← Merits + 1 |
| output inside the loop for each student | name, total, average, grade |
| counts output after the loop | one line at the end |
Common mistakes
| Wrong | Right | Why |
|---|---|---|
Total ← 0 before the outer loop |
Total ← 0 inside it |
the second student would start with the first one's total |
StudentMark[Test, Student] |
StudentMark[Student, Test] |
the row is the student, the column is the test |
testing Average >= 40 first |
test >= 70 first |
a 75 would be graded Pass |
| counts output inside the loop | output them after the loop | they are only complete when every student is done |
| answer written as one long paragraph | indented pseudocode with comments | the examiner looks for each mark point in the code |
Now you try
- Before writing, list the mark points from the question, one line each. Tick them as you write.
Independent transfer
The final task reads the students one at a time. Plan the loop, the reset and the "best so far", then solve it before opening support. Check a tie for the top average.
الصعوبة 1/5 · 100 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
In the lesson's data, what is StudentMark[3, 2]?
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Three students each have two marks. For each student, total the marks and output the name, a space and the total, one student per line.
اضغط تشغيل لرؤية المخرجات هنا.
الصعوبة 4/5 · 280 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Read how many students there are (1 to 5). For each student, read a name and then three marks. Output the name, a space and the average rounded to a whole number. At the end, output Top: and the name with the highest average; on a tie, keep the first.
اضغط تشغيل لرؤية المخرجات هنا.