Fig. 1 shows a section of a game program that validates a move on a 10 by 10 board. The player enters a row number into row. The program should reject row n...

Assessment: Computer Science 9210 | Paper 1 Mock 01 | Programming (on-screen) Subject: Computer Science - 9210

Question 1 Report

Fig. 1 shows a section of a game program that validates a move on a 10 by 10 board. The player enters a row number into row. The program should reject row numbers outside 1 to 10. A message is displayed when the entered row is invalid.

Enter rowrow < 1 ORrow > 10?TrueInvalid moveFalseMake move© EAGLE BEACON GLOBAL

(a) Explain why the relational tests are joined with OR. [1]
(b) When row is 0, state the path followed. [1]
(c) When row is 10, state the path followed. [1]
(d) When row is 14, explain which relational test is true. [1]
(e) When the board is changed to 12 rows, write the amended invalid-row condition. [1]



The canteen's allergy checker compares a selected meal code with a restricted code held in restrictedMeal. The code chosen by a student is stored in mealCode. If the two values are equal, the program must display a message and call a subroutine that suggests an alternative meal.

(a) Explain the Boolean result when mealCode = "P17" and restrictedMeal = "P17". [1]
(b) When the codes are "P17" and "V04", state the result of mealCode = restrictedMeal. [1]
(c) When the codes are equal, write two commands that could form the THEN block. [2]

Answer Details

Game-board validation

  1. OR is used because a row is invalid if it is below the minimum of 1 or above the maximum of 10. It cannot be both at once. [1]
  2. When row is 0, row < 1 is true. The flowchart follows the true path to Invalid move. [1]
  3. When row is 10, neither row < 1 nor row > 10 is true. It follows the false path to Make move. [1]
  4. When row is 14, the true relational test is row > 10. [1]
  5. For a 12-row board, the invalid-row condition is:
    row < 1 OR row > 12 [1]

Allergy checker

  1. If both codes are "P17", they are equal, so mealCode = restrictedMeal is true. [1]
  2. If the codes are "P17" and "V04", they differ, so the equality test is false. [1]
  3. A suitable THEN block is:
    DISPLAY "Restricted meal selected"
    CALL suggestAlternative()

    The display warns the user and the subroutine provides the required alternative-meal action. [2]

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