Question bank › GCSE Computer Science › Producing robust programs

Defensive design: validation, authentication, maintainability

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

1Grade 1–32 marks

Give two ways a programmer can make their code easier to maintain. [2]

2Grade 4–54 marks

A school's online form collects pupil details. Name the most suitable validation check for each input. [4]

InputRule
AgeMust be between 11 and 18
PostcodeMust follow the pattern of a UK postcode
SurnameMust not be left blank
PasswordMust be at least 8 characters
3Grade 6–74 marks

Write code that asks the user to enter their age. The program must keep asking until an age between 11 and 18 inclusive is entered. Use OCR Exam Reference Language or a high-level programming language. [4]

4Grade 8–96 marks

A system stores the username "admin" and the password "Pa55word".

Write an algorithm that:

• asks the user to enter a username and password

• allows a maximum of 3 attempts

• outputs "Access granted" if both are correct

• outputs "Locked out" after 3 incorrect attempts.

Use OCR Exam Reference Language or a high-level programming language. [6]

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