Question 1 Report
A community bus uses a program to display whether a passenger may use a discounted fare. The code editor receives the passenger's age as an integer. Table 1 shows test data entered during a test of the program. The word eligible is a Boolean variable. The program should set eligible to TRUE when the age is less than 16 or greater than or equal to 65. It must then display the correct message.
| Test number | age input | Expected display |
|---|---|---|
| 1 | 12 | Discount available |
| 2 | 16 | Standard fare |
| 3 | 65 | Discount available |
Table 1: test data for the bus-fare program
(a) Identify the data type of age. [2]
(b) Complete this condition: IF age < 16 OR age ______ 65 THEN [2]
(c) Use Table 1 to write the value of eligible for test number 2 and the message displayed for test number 3. [2]
(a) age is an integer [1]. It stores whole-number data, with no decimal values [1]. [2]
(b) The completed condition is:
IF age < 16 OR age >= 65 THEN
>= includes age 65 itself, which is important because passengers aged 65 qualify. [2]
(c) For age 16, neither age < 16 nor age >= 65 is true, so eligible is FALSE [1]. For age 65, the second test is true, so the display is Discount available [1]. [2]
Everything you need to excel in your exams