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...

Assessment: Computer Science 4CP0 | Paper 2 Mock 01 | Written Paper 2 Subject: Computer Science - 4CP0

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 numberlapTime (s)Expected result
114Reject
215Accept
394Accept
4181Reject

(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]

Answer Details

(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 IF

The condition gains [1], the required display gains [1], and valid closing syntax gains [1]. [3]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning