Question 1 Report
A museum is creating a touchscreen quiz about local fossils. The skeleton program stores a player's score in score. When the player chooses the correct answer, the program must add one point before the next question is displayed.
(a) Explain why score should be stored as an integer rather than a string. [1]
(b) When the player gives a correct answer, write one program statement that updates score. [1]
(c) Explain why the score variable should be set to zero at the start of a new game. [1]
The table below shows test data entered into a school canteen ordering program. The program accepts an item code only when it has exactly three characters and starts with a letter.
| Test | Item code entered | Expected result |
|---|---|---|
| 1 | A12 | accepted |
| 2 | 123 | rejected |
| 3 | AB12 | rejected |
| 4 | Z99 | accepted |
(a) Explain why test 2 should be rejected. [1]
(b) When the programmer tests the boundary of the length rule, state one new item code that should be used. [1]
(c) Explain why both normal and erroneous test data are needed before the ordering program is used. [1]
Quiz program
(a) score should be an integer because points must be added using arithmetic. [1]
(b) A suitable increment statement is score = score + 1. [1]
(c) Setting the score to zero starts a new game fairly and prevents a new player receiving points from a previous game. [1]
Canteen ordering program
(a) 123 is rejected because its first character is a number, not a letter. [1]
(b) A suitable new boundary-length test is AB, which has two characters. ABCD, with four characters, is also acceptable. [1]
(c) Normal data checks that valid entries are accepted in ordinary use. Erroneous data checks that invalid entries are rejected or handled safely. Both are needed. [1]
Everything you need to excel in your exams