← Back to Dashboard

2.3 Robust Programs

GCSE Computer Science (J277)

1. Jack is writing a program to add up some numbers. His first attempt at the program is shown.
Give two ways that the maintainability of this program could be improved
[2]
Question Image
Login to save your answers
/ 2
2. When a new booking is recorded, the details are entered into a program to validate the
values. The following criteria are checked:
• firstName and surname are not empty
• room is either “basic” or “premium”
• nights is between 1 and 5 (inclusive).
If any invalid data is found “NOT ALLOWED” is displayed.
If all data is valid “ALLOWED” is displayed.

Complete the following program to validate the inputs.

You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied.
[5]
Question Image
Login to save your answers
/ 5
3. The hotel has nine rooms that are numbered from room 0 to room 8.
The number of people currently staying in each room is stored in an array with the identifier
room.
The index of room represents the room number.

The following program counts how many people are currently staying in the hotel.

for count = 1 to 8
total = 0
total = total + room[count]
next count
print(total)

When tested, the program is found to contain two logic errors. Describe how the program can be refined to remove these logic errors.
[2]
Question Image
Login to save your answers
/ 2
4. When a new booking is recorded, the details are entered into a program to validate the values. The following criteria are checked:
• firstName and surname are not empty
• room is either “basic” or “premium”
• nights is between 1 and 5 (inclusive).

If any invalid data is found “NOT ALLOWED” is displayed.
If all data is valid “ALLOWED” is displayed

Complete the following test plan to check whether the number of nights is validated correctly.
[3]
Login to save your answers
/ 3
Please login to save your answers and marks.