Question 1 Report
The attendance program at an outdoor climbing club checks a participant's signed consent form. The variable consent stores either "YES" or "NO". Before the participant is added to the climbing list, the program needs to reject every value except "YES".
IF consent = "NO" THEN
DISPLAY "Consent required"
ENDIF
A coordinator notices that an accidental entry of "MAYBE" receives no message.
(a) Explain why the existing equality test does not deal with "MAYBE". [1]
(b) When the value is anything other than "YES", write a condition that displays the message. [1]
(c) When consent is "YES", state the Boolean result of your condition. [1]
(d) Explain why the new condition is more reliable for this program. [1]
A sports hall booking program checks that a requested court number is valid before it stores a new booking. Courts are numbered 1 to 4. The number typed by a player is stored in court. The programmer proposes this condition:
IF court >= 1 AND court <= 4 THEN
CALL saveBooking()
ENDIF
The subroutine must not be called for court 0 or court 5.
(a) Explain the purpose of the relational operation court >= 1. [1]
(b) When court is 4, state whether saveBooking() is called. [1]
(c) When court is 5, explain why the full condition is false. [1]
Consent validation
"MAYBE" is not equal to "NO", so consent = "NO" is false and no message is displayed. [1]consent <> "YES" [1]consent is "YES", this condition is false. [1]"NO". [1]Court booking
court >= 1 checks that the court number is at least 1, so it is not below the valid range. [1]court is 4, both tests are true, so saveBooking() is called. [1]court is 5, court <= 4 is false. Since both conditions must be true with AND, the full condition is false. [1]Everything you need to excel in your exams