Figure 1 shows an algorithm designed to validate booking times at a sports court and calculate the duration of the booking.
Figure 1
1 validBooking ← False
2 REPEAT
3 duration ← -1
4 OUTPUT 'Enter start hour'
5 startHour ← USERINPUT
6 OUTPUT 'Enter end hour'
7 endHour ← USERINPUT
8 IF startHour ≥ endHour THEN
9 OUTPUT 'Start hour must be before end hour'
10 ELSE
11 IF startHour > 12 THEN
12 OUTPUT 'Start hour must be before noon'
13 ELSE
14 validBooking ← True
15 ENDIF
16 ENDIF
17 UNTIL validBooking = True
18 duration ← endHour - startHour
19 OUTPUT duration
Table 1 shows three tests used to check the algorithm in Figure 1.
Complete the table to show what the values of the validBooking and duration variables would be at the end of each independent test execution.
Table 1
| Test type | Test data | validBooking | duration | |
|---|---|---|---|---|
| Normal | startHour | 10 | ||
| endHour | 15 | |||
| Erroneous | startHour | 14 | ||
| endHour | 11 | |||
| Boundary | startHour | 12 | ||
| endHour | 16 |
208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.