Worked example · IT · Year 7
DCF: Data and computational thinking → Problem-solving and modelling
A secure Year 7 response, annotated so you can see which success criterion each part meets. It is also the answer key. Key figures: Order A change 70p; Order B total 230p, change 270p; Order C change 5p; cheapest 3-item order 185p; a week of it £9.25 with 75p left; Ffion’s plan with toast £10.50, 50p over budget. The bugs are in box 6 and box 9.
| Type of box | Box number | What happens |
|---|---|---|
| Input | 3 (or 8) | The price of an item is typed in (box 8: the money paid). |
| Process | 4 (or 2, 7, 11) | The price is added to the total and 1 is added to items. |
| Decision | 6 (or 5, 9) | Asks if there are 3 or more items, to decide on the discount. |
| Output | 12 (or 10) | Shows the change and the coins to give. |
Any correct box number is fine. Evidences criterion 1.
Order A (Rhys)
| Box | items | total | paid | change | Output |
|---|---|---|---|---|---|
| 2 | 0 | 0 | |||
| 4 | 1 | 60 | |||
| 4 | 2 | 130 | |||
| 8 | 2 | 130 | 200 | ||
| 11 | 2 | 130 | 200 | 70 | |
| 12 | 70p: 50p, 20p |
Order B (Ffion)
| Box | items | total | paid | change | Output |
|---|---|---|---|---|---|
| 2 | 0 | 0 | |||
| 4 | 1 | 90 | |||
| 4 | 2 | 175 | |||
| 4 | 3 | 255 | |||
| 7 | 3 | 230 | |||
| 8 | 3 | 230 | 500 | ||
| 11 | 3 | 230 | 500 | 270 | |
| 12 | £2.70: £2, 50p, 20p |
Order C (Osian)
| Box | items | total | paid | change | Output |
|---|---|---|---|---|---|
| 2 | 0 | 0 | |||
| 4 | 1 | 120 | |||
| 4 | 2 | 205 | |||
| 8 | 2 | 205 | 200 | ||
| 10 | Not enough money | ||||
| 8 | 2 | 205 | 210 | ||
| 11 | 2 | 205 | 210 | 5 | |
| 12 | 5p: 5p |
One row for every value that changes, in the order the boxes run. The pupil spots that box 7 only runs for Order B, and that Order C goes round the loop from box 10 back to box 8. Evidences criterion 2.
| Change | Coins given | Number of coins |
|---|---|---|
| £2.70 | £2, 50p, 20p | 3 |
| 38p | 20p, 10p, 5p, 2p, 1p | 5 |
| 95p | 50p, 20p, 20p, 5p | 4 |
| £3.65 | £2, £1, 50p, 10p, 5p | 5 |
Starting with the biggest coin uses up as much of the change as possible each time, so fewer coins are needed. If it started with 1p coins, 95p would be 95 coins.
Each line of coins adds up to the change (50 + 20 + 20 + 5 = 95). Evidences criteria 2 and 5.
| Test | Order and money paid | Expected output and working |
|---|---|---|
| 1 | Toast, water. Pays 200p. | 60 + 70 = 130. 200 − 130 = 70. Change 70p (50p, 20p). |
| 2 | Toast, water, fruit pot. Pays 200p. | 60 + 70 + 80 = 210. 3 items, so 210 − 25 = 185. 200 − 185 = 15. Change 15p (10p, 5p). |
| 3 | Flapjack. Pays 90p. | Total 90. 90 is not less than 90, so no message. Change 0p, no coins. |
| 4 | Cheese roll. Pays 100p. | Total 120. 100 is less than 120, so “Not enough money”. |
| 5 | Toast, toast, water, juice. Pays 300p. | 60 + 60 + 70 + 85 = 275. 4 items, so 275 − 25 = 250. Change 50p (50p). |
The expected output is worked out from the rules, not from what the till does, which is the whole point of a test. Evidences criteria 3 and 5.
Tests 1, 4 and 5 pass. Tests 2 and 3 fail.
(a) Test 2 fails because Version 2 gave no discount for exactly 3 items: 210 is more than 200, so it said “Not enough money”. Box 6 probably says Is items more than 3? It should say Is items 3 or more?
Test 3 fails because paying exactly 90p for a 90p flapjack is enough. Box 9 probably says Is paid less than or equal to total? It should say Is paid less than total?
(b) 4 items is more than 3 and 3 or more, so both versions give the discount. The bug only shows at exactly 3. You have to test right on the edge of a rule, because that is where mistakes hide.
Each bug is linked to a numbered box with the wrong and the corrected wording, and the pupil explains why a test away from the edge missed it. Evidences criterion 4.
(a) The 3 cheapest items are toast, water and fruit pot: 60 + 70 + 80 = 210, minus 25 = 185p = £1.85.
(b) 185 × 5 = 925p = £9.25. 1,000 − 925 = 75p, so 75p is left.
(c) 90 + 85 = 175p a day. 175 × 5 = 875p = £8.75. With toast: 175 + 60 = 235, minus 25 = 210p. 210 − 175 = 35, so yes, it costs 35p more a day. But 210 × 5 = 1,050p = £10.50, which is 50p over her £10. She can only do it on 3 days: 3 × 210 + 2 × 175 = 630 + 350 = 980p.
| Day | Items | Cost (pence) | Discount? |
|---|---|---|---|
| Monday | Cheese roll, water | 120 + 70 = 190 | No |
| Tuesday | Toast, fruit pot, water | 210 − 25 = 185 | Yes |
| Wednesday | Flapjack, water | 90 + 70 = 160 | No |
| Thursday | Toast, juice, fruit pot | 225 − 25 = 200 | Yes |
| Friday | Cheese roll, juice | 120 + 85 = 205 | No |
| Week total | 940p = £9.40 | Left from £10: 60p |
Working is shown in pence and every answer is converted to pounds. In (c) the pupil checks Ffion’s claim, then sees that a small daily cost adds up over a week. Evidences criterion 5.
New rule: decision box Is total more than 300?, Yes goes to process box total = total − total ÷ 10. For £3.20, 10% is 32p, which beats 25p by 7p.
Test 1 would catch it: 130 − 200 = −70, so the till would show change of −70p, which makes no sense.