HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /This is the kind of long scenario question that ends Paper 2…
HardComputer ScienceHigh School (9–10)Computer Science › Algorithms and Problem-SolvingcodingConceptualIGCSE

This is the kind of long scenario question that ends Paper 2…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

This is the kind of long scenario question that ends Paper 2. Answer in pseudocode.

A teacher wants a program for the results of a class test. The program must:

  • input the number of pupils in the class;
  • for each pupil, input the name and the mark;
  • accept only marks from 000 to 100100100, asking again with a message for any other mark;
  • output the class average, rounded to one decimal place;
  • output the highest mark and the name of the pupil who scored it;
  • output how many pupils scored 505050 or more.

Write the algorithm with comments. Then give its outputs for a class of 444: Ana 676767, Ben 454545, Chen first typed as 108108108 and then corrected to 888888, and Dev 505050.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

Totalling: Total ← 0 before the loop, Total ← Total + Value inside. Counting: Count ← 0 before, Count ← Count + 1 inside (often in an IF). Maximum and minimum: start with the first value or an extreme value, and replace it with any larger (or smaller) value. Average: Total / Count after the loop.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Plan. One FOR loop over the pupils; inside it a validation loop for the mark, then totalling, counting and the maximum.

A model answer.

pseudocode
// Class test results
INPUT Size
Total ← 0
Passes ← 0
Highest ← -1
FOR Pupil ← 1 TO Size
    INPUT Name
    REPEAT
        INPUT Mark
        IF Mark < 0 OR Mark > 100
          THEN
            OUTPUT "Mark must be 0 to 100: enter it again"
        ENDIF
    UNTIL Mark >= 0 AND Mark <= 100
    Total ← Total + Mark
    IF Mark >= 50
      THEN
        Passes ← Passes + 1
    ENDIF
    IF Mark > Highest
      THEN
        Highest ← Mark
        TopName ← Name
    ENDIF
NEXT Pupil
OUTPUT "Average: ", ROUND(Total / Size, 1)
OUTPUT "Highest: ", Highest, " by ", TopName
OUTPUT "Marks of 50 or more: ", Passes

The run. The 108108108 is refused with the message, and 888888 is accepted. Total =67+45+88+50=250= 67 + 45 + 88 + 50 = 250=67+45+88+50=250, so the average is 250÷4=62.5250 \div 4 = 62.5250÷4=62.5. The highest mark is 888888, by Chen. The marks of 505050 or more are 676767, 888888 and 505050: 333 pupils.

A marking list. One mark for each point.

  1. Input the number of pupils.
  2. A loop that runs once for each pupil.
  3. Input the name inside the loop.
  4. Input the mark inside the loop.
  5. A loop that repeats the mark until it is from 000 to 100100100.
  6. An error message for a mark out of range.
  7. Total starts at 000 before the loop.
  8. Each valid mark is added to Total.
  9. Passes starts at 000 and goes up for a mark of 505050 or more (the boundary 505050 included).
  10. Highest starts low (or at the first mark).
  11. A larger mark replaces Highest.
  12. The name is stored with the highest mark.
  13. The average is Total / Size, worked out after the loop.
  14. The average is rounded to one decimal place.
  15. All three results are output with messages.

Answer: average 62.562.562.5, highest 888888 by Chen, and 333 pupils with 505050 or more.

What if? If two pupils share the highest mark, this algorithm keeps the first, because it uses >. With >= it would keep the last.

Log in to save this for later
← All Problems
← A freezer records four temperatures in degrees Celsius: -3, -8, -1 and -6…A club keeps its eight members in an array in the order they joined: Ines, Kofi, Hana, Luis, Ama… →
More onComputer Science › Algorithms and Problem-Solving

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Totalling, counting, maximum, minimum and averageStandard Algorithms: Totals, Searching, Sorting and Validation

More on this topic

  1. A delivery company adds a check digit to each parcel number…Medium
  2. Name the check in each case. Say whether it is validation or verification…Easy
  3. A bubble sort is changed so that it sorts in descending order: the comparison becomes IF…Hard
A shop stores the colours of the ten bicycles in its window in an array Colours: red, blue, red…Medium
  • A bubble sort puts the scores 5, 1, 4, 2, 8 into ascending order…Medium
  • All problems on this topic →