Question 1 Report
A sports centre records lap times from a swimming lane sensor. The program reads a number of times in seconds and must reject any time below 15 or above 180. Valid times are added to totalTime. Table 1 shows four inputs used while testing the validation code. The variable validCount is also increased only for valid data. The programmer needs to choose the correct Boolean operator so that invalid input is identified reliably.
| Input number | lapTime (s) | Expected result |
|---|---|---|
| 1 | 14 | Reject |
| 2 | 15 | Accept |
| 3 | 94 | Accept |
| 4 | 181 | Reject |
(a) Identify the two input numbers that should not be added to totalTime. [1]
(b) Complete the condition: IF lapTime < 15 ______ lapTime > 180 THEN [2]
(c) Write pseudocode that displays "Invalid time" when the condition is true. [3]
(a) Inputs 1 and 4 should not be added to totalTime [1]. They are 14 s, below 15 s, and 181 s, above 180 s.
(b) An invalid value can be too low or too high, so use:
IF lapTime < 15 OR lapTime > 180 THEN
AND would be impossible here because one value cannot simultaneously be below 15 and above 180. [2]
(c) The selection to display the error is:
IF lapTime < 15 OR lapTime > 180 THEN
DISPLAY "Invalid time"
END IFThe condition gains [1], the required display gains [1], and valid closing syntax gains [1]. [3]
Everything you need to excel in your exams