ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
5 marks · Input validation
Using a design technique of your choice, design an efficient solution to ensure that the program will only accept valid numbers from the user. State a numerical example of exceptional test data that could be used to test the design. Input validation is required to ensure that a program will only accept the numbers 1 or 5.
One mark each for • conditional loop • loop condition • input inside loop • error message. The loop conditional may change depending on where the candidate uses a pre or post conditional loop. For example: • until num = 1 or num = 5 • while num ≠ 1 and num ≠ 5 Where the candidate’s design indicates a pre-conditional (while) loop a second input should be shown inside the loop Any numerical value that is neither 1 or 5.