Cover lesson · IT · Year 7 · Beginner

Tracing a tuck shop till algorithm

DCF: Data and computational thinking → Problem-solving and modelling

Name: Class: Date:

Cover teacher: you need no subject knowledge

What this practises: following an algorithm step by step (tracing), choosing test data, and finding bugs, all on paper. The money work (pence and pounds, change, a weekly budget) is real numeracy and is marked from the sheet.

Print: this sheet, one per pupil, and the stimulus sheet “Siop Fach: the tuck shop till”, one between two. No computers are needed. Calculators are not needed; all the sums are small.

Run: 5 min read the stimulus sheet aloud and do Step 1 · 15 min Step 2 · 7 min Step 3 · 10 min Step 4 · 8 min Step 5 · 10 min Step 6. Total 55 minutes.

Collect: this sheet. Quick checks: Order A change 70p (50p, 20p); Order B pays £2.30, change £2.70 (£2, 50p, 20p); Order C first shows “Not enough money”, then change 5p. The two bugs in Step 5 are in box 6 and box 9.

What you are doing

The IT department has written a till program for Siop Fach, the school tuck shop. Before it goes live, you are the tester. You will follow the flowchart exactly as a computer would, record what happens to each value, design tests that could catch mistakes, find the bugs in a second version, and then use the prices to plan a week of break-time snacks on a budget.

Step 1: the shapes

Look at the flowchart on the stimulus sheet. Write the number of one box of each type.

Type of boxBox numberWhat happens in that box
Input (data goes in)
Process (the till works something out)
Decision (Yes or No question)
Output (data comes out)

Step 2: trace three orders

Follow the flowchart for each order. Every time a value changes, write the new value on the next row of the trace table. Work in pence. The first rows of Order A are done for you.

Order A (Rhys): toast, bottle of water. He pays with a £2 coin.

BoxitemstotalpaidchangeOutput
200
4160

Order B (Ffion): flapjack, fruit juice, fruit pot. She pays with a £5 note.

BoxitemstotalpaidchangeOutput

Order C (Osian): cheese roll, fruit juice. He hands over £2. When the till asks again, he hands over £2.10 instead.

BoxitemstotalpaidchangeOutput

Step 3: the fewest coins

Use the method in section 4 of the stimulus sheet. Write the coins the till gives and how many coins that is.

ChangeCoins givenNumber of coins
Order B: £2.70
38p
95p
£3.65

Why does the till start with the biggest coin and not the smallest?

Step 4: plan the tests

Good testers choose data that could catch a mistake, especially at the edges of a rule (exactly 3 items, or paying the exact amount). Work out what a correct till should output for each test.

TestWhat it checksOrder and money paidExpected output (show your working)
12 items: no discountToast, water. Pays 200p.130 total, change 70p (50p, 20p)
2Exactly 3 items: discountToast, water, fruit pot. Pays 200p.
3Pays the exact amountFlapjack. Pays 90p.
4Not enough moneyCheese roll. Pays 100p.
5More than 3 itemsToast, toast, water, juice. Pays 300p.

Step 5: find the bugs

The programmer made a Version 2 of the till. They ran your five tests on it and got these outputs.

TestVersion 2 outputPass or fail? 
1Change 70p (50p, 20p)
2“Not enough money”
3“Not enough money”
4“Not enough money”
5Change 50p (50p)

(a) For each failed test, which box do you think is wrong? Write what that box probably says in Version 2, and what it should say.

(b) Test 5 passed, even though Version 2 has a bug in the discount box. Explain why. What does this tell you about choosing test data?

Step 6: a week on a budget

Show your working in pence, then give each answer in pounds and pence.

(a) Which 3 items make the cheapest order? How much does that order cost after the discount?

(b) Gwen has £10 for the week. If she buys that cheapest order every day from Monday to Friday, what does the week cost, and how much is left?

(c) Ffion buys a flapjack and a fruit juice every day (2 items, no discount). What does that cost for 5 days? She thinks adding toast each day will only cost her 35p more a day, because of the discount. Is she right? Can she do this every day on £10?

(d) Plan your own week at Siop Fach on a £10 budget. You must buy at least 2 items every day.

DayItemsCost (pence)Discount?
Monday
Tuesday
Wednesday
Thursday
Friday
Week total Left from £10:

Step by step

  1. 5 min Read the stimulus sheet with your teacher. Step 1: find one box of each type.
  2. 15 min Step 2: trace Orders A, B and C. Go one box at a time; do not jump ahead.
  3. 7 min Step 3: change in the fewest coins.
  4. 10 min Step 4: work out the expected output for each test.
  5. 8 min Step 5: compare Version 2 with your expected outputs and find the bugs.
  6. 10 min Step 6: the budget questions and your own week.

Success criteria

If you finish early