Worked example · Computer Science · Year 8

DIV and MOD for a quiz timer

LNF: Numeracy → Developing mathematical proficiency → Communicating with symbols

What this is

A complete, secure Year 8 answer, annotated so you can see which success criterion each part meets. It is also the answer key. Headline answers: 95 s shows 1:35, 200 s 3:20, 359 s 5:59, 600 s 10:00; 3,725 s is 1:02:05. R1 is time <= 10 and R2 is question MOD 3 = 0. In the test log, L1 to L5 are wrong and L6 is correct. The most common mistake is treating the decimal from / as minutes and seconds (2.08 is not 2 min 8 s).

Step 1: DIV and MOD warm-up

a and ba DIV ba MOD bCheck
17 and 5323 * 5 + 2 = 17
23 and 4535 * 4 + 3 = 23
30 and 6505 * 6 + 0 = 30
7 and 10070 * 10 + 7 = 7
100 and 714214 * 7 + 2 = 100

7 DIV 10 = 0 and 7 MOD 10 = 7 are the tricky ones: 10 goes into 7 no whole times, so all 7 is left over. Evidences criterion 1.

Step 2: the timer

time (s)DIV 60MOD 60In wordsDisplayCheck
951351 min 35 s1:351 * 60 + 35 = 95
125252 min 5 s2:052 * 60 + 5 = 125
2003203 min 20 s3:203 * 60 + 20 = 200
3595595 min 59 s5:595 * 60 + 59 = 359
60010010 min 0 s10:0010 * 60 + 0 = 600

(b) The seconds part is always shown as 2 digits, because 2:5 could be misread as 2 min 50 s. The 0 in 2:05 holds the tens place.

Every result is checked by reversing it. Units are written with a space and the display has none. Evidences criteria 1, 2 and 5.

Step 3: hours as well

hours = time DIV 3600 minutes = (time MOD 3600) DIV 60 seconds = time MOD 60

(b) 3725 DIV 3600 = 1. 3725 MOD 3600 = 125, and 125 DIV 60 = 2. 3725 MOD 60 = 5. So 3,725 s = 1 h 2 min 5 s, displayed as 1:02:05. Check: 3,600 + 120 + 5 = 3,725.

Brackets show the order: find what is left after the hours first, then divide that by 60. Evidences criteria 1 and 5.

Step 4: rules into symbols

RuleCondition
R1time <= 10
R2question MOD 3 = 0
R3score >= 50 OR time > 600
R4age >= 11 AND age <= 14
R5answer <> correct
R6question MOD 2 = 0

(b) time = 8: TRUE. time = 10: TRUE (“or less” includes 10). time = 12: FALSE.

(c) Questions 3, 6, 9 and 12. For these, question MOD 3 = 0 because 3 goes in exactly with nothing left over. For example 9 MOD 3 = 0, but 10 MOD 3 = 1.

(d) time = 10. The rule says 10 seconds should get the bonus, but 10 < 10 is FALSE, so Ifan’s condition gives no bonus.

“Or less” becomes <=, “or over” becomes >=, and “more than” becomes >. The pupil tests the boundary value, 10, which is where mistakes show. “Every 3rd” is turned into MOD. Evidences criterion 3.

Step 5: Efa’s test log

LineCorrect?What is wrongCorrect form
L1No2.08 is 2.08 minutes, not 2 min 8 s. The decimal part is a fraction of a minute.125 DIV 60 = 2, 125 MOD 60 = 5, display 2:05
L2NoDIV only gives the whole-number part. “r 20” is not part of DIV.200 DIV 60 = 3 and 200 MOD 60 = 20
L3NoMixes a display with a unit. 5:59 min looks like a decimal of minutes.359 s = 5 min 59 s (display 5:59)
L4No60 goes into 600 exactly, so the remainder is 0. 10 is the DIV answer.600 MOD 60 = 0 (and 600 DIV 60 = 10)
L5No=< is not a symbol. The characters are in the wrong order.time <= 10
L6YesCorrect units and spacing.

Each correction says what the error is, not just the right answer. Evidences criterion 4.

Step 6: why symbols? (model)

A program cannot decide what “quickly” or “about 10 seconds” means, and two people might disagree about 11 seconds. time <= 10 has exactly one meaning: 10 and below get the bonus, and everything above does not.

If you finish early: answers

Why this response is secure