Cambridge O Level Computer Science 2210 · 7.5 Validation and verification checks

Q24 · 2210/22/M/J/23 Q4

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 4 of 8.

Q242210/22/M/J/23original Q4Structured · 7 marks
Question 4 from 2210/22/M/J/23

Worked solution

(a)

Match one check to each rule. Any three of these:

Range check: the value must be greater than 0 and less than 1000 [1]

Presence check: a value must be entered, so the program cannot go on with an empty input [1]

Type check (character check): make sure a number is entered, not letters [1]

A length check also scores: no more than 3 digits are entered.

(b)(i)

Write: it is a verification check, to make sure the data has not changed or been mistyped when it was entered [1]

(b)(ii)

Use a loop that asks for the value twice and repeats until both inputs match.

REPEAT
    OUTPUT "Please enter measurement "
    INPUT Measurement
    OUTPUT "Please re-enter measurement "
    INPUT MeasurementCheck
UNTIL Measurement = MeasurementCheck

Iteration used (REPEAT ... UNTIL or any working loop) [1]

Two inputs, one stored in the variable Measurement [1]

The loop ends only when the two inputs are compared and are the same [1]

KEY IDEAValidation checks that data is sensible; verification (double entry) checks that it was entered correctly.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/22/M/J/23 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by CS BY AQIB KHAN. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.