Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
Question 42
Easy

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]

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms