Question bank › GCSE Computer Science › Programming

Data validation & authentication routines

Answer on paper first, then reveal the mark scheme one mark at a time.

1Grade 1–33 marks

State the type of validation check being described in each case. [3]

(a) An exam mark entered must be between 0 and 100.
(b) The username field must not be left empty.
(c) A password must contain at least 8 characters.

2Grade 6–75 marks

A program asks the user how many concert tickets they want to buy. The number must be between 1 and 6 inclusive.

Write an algorithm, using pseudo-code or program code, that keeps asking the user to enter the number of tickets until a valid number is entered, displaying an error message each time an invalid number is entered. You may assume the user always enters an integer. [5]

3Grade 6–75 marks

This algorithm is an authentication routine.

attempts ← 0
REPEAT
   OUTPUT 'Enter password'
   pw ← USERINPUT
   attempts ← attempts + 1
UNTIL pw = 'Tr0ub4dor' OR attempts = 3
IF pw = 'Tr0ub4dor' THEN
   OUTPUT 'Access granted'
ELSE
   OUTPUT 'Locked'
ENDIF

(a) The user enters abc then Tr0ub4dor. State the final value of attempts and the final output. [2]

(b) State the final output if the user enters red, blue and then green. [1]

(c) Explain how limiting the number of attempts makes the system more secure. [1]

(d) Suggest one other way the authentication could be made more secure. [1]

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro