Skip to content
MathsGenie logo
Open app

Course home

  1. GCSE
  2. Computer Science Edexcel
  3. Question bank

Computational thinking

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
Question 46

TicketCalc classifies cinema tickets by category according to a customer's age.

Here is the pseudo-code for an algorithm that determines the qualification category of a customer.

2 SET ageBoundaries TO [2, 12, 18, 65]
3 SET ticketType TO ["Infant", "Child", "Youth", "Adult", "Senior"]
4 SET found TO False
5 SET i TO 0
6
7 SEND "Enter age" TO DISPLAY
8 RECEIVE inAge FROM (INTEGER) KEYBOARD
9
10 WHILE (found = True) AND (i < LENGTH(ageBoundaries)) DO
11     IF (inAge > ageBoundaries[i]) THEN
12         SET i TO i + 1
13     ELSE
14         SET found TO True
15     END IF
16 END WHILE
17 SEND ticketType[i] TO DISPLAY

The pseudo-code produces an incorrect output.

When the user enters 15, the algorithm outputs "Infant". The correct output should be "Youth".

State the name for this type of error.

[1]

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking