Computer Science · Oct / Nov 2022 · Paper 22 · Question 1
0478
As printed in the paper
The question as text
All variables, constants and other identifiers must have meaningful names.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
1(a)(i)[2]
Many correct answers, the name used must be meaningful. The name given is an example only.
One mark per mark point, max two
Constant NumberDays …Value … 14Task 1 – setting up the booking system
Set up suitable data structures to store the car licence numbers and names of visitors who have booked car parking spaces. The data structures should have sufficient capacity to store data for each of the 20 parking spaces for a static period of two weeks. Allow a visitor to request a parking space on any day within the two-week period by entering a number between 1 and 14, inclusive. The system will check that there are spaces available on the day requested, and if so, will ask the visitor to enter their name and car licence number. This data will be stored in the data structures
representing the first available parking space for the day requested. The visitor will be told the number of their parking space.
At the end of the two-week period, allow all of the data to be deleted ready for the next two-week period.
1(a)(ii)[2]
Many correct answers, the name used must be meaningful. The name given is an example only.
One mark per mark point, max two
ArrayLicenceNumbers …
Use… storing the licence numbers of the cars to be parked
1(b)[3]
One mark per mark point, max two
MP1
use a (range) check to check for values between 1 and 14
MP2
use a (type) check to ensure an integer is entered
MP3
… using an (appropriate) IF/conditional statement
MP4
outputs an error message if a new input is required
MP5
re-enter data using WHILE/REPEAT loop until a valid entry has been made
One mark
MP6
appropriate line of code / construct to answer the question
Example code
INPUT Day
WHILE Day < 1 OR Day > 14 DO
OUTPUT "You must enter a number between 1 and 14 inclusive"
INPUT Day
ENDWHILE
1(c)[6]
One mark per mark point, max six
MP1
input for day number or to choose accessible parking …
MP2
… both inputs with appropriate prompts
MP3
conditional statement to check if accessible parking is required
MP4
initialisation of variable for the first accessible space
MP5
checking if current array element is an available space
MP6
correct loop to check all array elements for the day
MP7
… until an available space is found (or not)
MP8
input car licence number and name (with or without prompts)
MP9
… and store them in the correct array position(s)
MP10
appropriate output for space available or no space available
MP11
appropriate output for allocated parking space details
Task 2 – adding accessible parking spaces
The visitor car park booking system is to be re-designed to offer accessible parking. Spaces 1 to 5 are named accessible spaces. Spaces 6 to 20 are named general spaces.
Extend your program in Task 1 so that:
when a visitor requests a parking space, they are additionally asked if they need an accessible spaceif so, they are allocated the first available space beginning at space 1 and finishing at space 20if not, they are allocated the first available space beginning at space 20 and finishing at space 6.The system must work so that visitors requiring accessible parking may be allocated any of the 20 spaces, but visitors who do not need accessible parking may only be allocated general spaces.
Example answer
//Assume LicenceNumber array has been initialised with the null string
OUTPUT "Enter the number of the day in which you require parking "
INPUT Day
OUTPUT "Do you require an accessible space? (Y or N)"
INPUT Accessible
IF Accessible = "Y"
THEN
SpaceAllocated ← FALSE
Space ← (Day - 1) * 20
REPEAT
IF LicenceNumbers[Space] = ""
THEN
OUTPUT "Enter your car licence number "
INPUT LicenceNumbers[Space]
SpaceAllocated ← TRUE
ENDIF
Space ← Space + 1
UNTIL SpaceAllocated OR Space = (Day - 1) * 20 + 20
IF NOT SpaceAllocated
THEN
OUTPUT "No space available"
ELSE
OUTPUT "You are allocated space: ", Space – (Day – 1) * 20
ENDIF
ENDIF
1(d)[3]
Explanation of how the following could be done:
One mark per mark point, max three
MP1
change the max constant to 560 / 28
MP2
change the output message for the user to say that the range of days entered must be from 1 to 28
MP3
alter the validation to allow an input of 1 to 28
MP4
change the size of the array that stores licence numbers / names so that it can hold the additional data
MP5
ensure that all loops that access the stored data for retrieval or erasing of data include the new full range
1(e)[4]
Explanation of how the following could be done:
One mark per mark point, max four
MP1
initialise counting variable(s) …
MP2
… for accessible spaces and general spaces before any spaces have been allocated
MP3
increment the counter(s) …
MP4
… for accessible spaces and general spaces
MP5
maintain both counters for the full two-week cycle
MP6
output to show the total number of accessible and general spaces allocated so far, with suitable messages
Task 3 – working out car park usage statisticsExtend the program to enable the following statistics to be counted and output on request:The number of accessible spaces used on any of the 14 days.The number of general spaces used on any of the 14 days.The total number of spaces used on any of the 14 days.The number of accessible spaces used in the whole 14-day period.The number of general spaces used in the whole 14-day period.The total number of spaces used in the whole 14-day period.Section B
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

