Computer Science · May / June 2024 · Paper 22 · Question 4
0478
As printed in the paper
The question as text
A program needs to make sure the characters input for a product code meet these rules: • The product code is six characters in length. • The first two characters must be “PD”. • The last four characters must be a number in the range 1000 to 9999 inclusive.
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
4(a)[6]
One mark per mark point
MP1
length check …
MP2
… to ensure the product code entered is 6 characters in length
MP3
format check …
MP4
… to ensure the first two characters of the product code entered are “PD”
MP5
range check …
MP6
… to ensure that the value of the last four figures of the product code entered is between 1000 and 9999
4(b)(i)[2]
One mark for correct use of LENGTH operation, one mark for appropriate test
Example:
REPEAT
INPUT Product
UNTIL LENGTH(Product) = 6
4(b)(ii)[2]
One mark for correct use of SUBSTRING operation, one mark for appropriate test
Example:
REPEAT
INPUT Product
UNTIL SUBSTRING(Product, 1, 2) = "PD"
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

