lnf.cymru stimulus sheet · Computer Science · Year 8

Cwis Cwm Ystrad: the quiz timer and the rules

The youth club, the quiz and Efa are invented. DIV, MOD and the comparison symbols are real and are used in programming.

1. The problem

Efa is programming a quiz for Cwm Ystrad youth club. Her program counts time in seconds, so after a round it shows “Time: 125”. The players want to see minutes and seconds, like “2:05”. Efa also needs to turn the club leader’s rules, written in words, into symbols the program can use.

2. Symbols used in programs

SymbolMeaningExample
*multiply2 * 60 = 120
/divide (can give a decimal)125 / 60 = 2.0833…
DIVwhole-number division: how many whole times125 DIV 60 = 2
MODthe remainder after whole-number division125 MOD 60 = 5
=is equal toscore = 10
<>is not equal toanswer <> 4
<is less thanage < 11
>is more thantime > 600
<=is less than or equal totime <= 10
>=is more than or equal toscore >= 50
ANDboth parts must be trueage >= 11 AND age <= 14
ORat least one part must be truescore >= 50 OR time > 600

Watch out: the symbol is <=, never =<. The two characters go in the same order as you say them: “less than, or equal to”.

3. How DIV and MOD work

17 DIV 5 = 3 because 5 goes into 17 three whole times 17 MOD 5 = 2 because 17 = 3 * 5 + 2, so 2 is left over Check: (17 DIV 5) * 5 + (17 MOD 5) = 3 * 5 + 2 = 17

4. Efa’s timer method

minutes = time DIV 60 seconds = time MOD 60 Show minutes, then a colon, then seconds as 2 digits. Example: time = 125 → 125 DIV 60 = 2, 125 MOD 60 = 5 → shows 2:05

Units: write s for seconds, min for minutes and h for hours, with a space after the number: 125 s = 2 min 5 s. The display 2:05 has no units. There are 60 s in 1 min and 3,600 s in 1 h.

5. The club leader’s rules, in words

RuleIn words
R1A player gets a speed bonus if they answer in 10 seconds or less.
R2Every 3rd question is a picture round.
R3The game ends when the score reaches 50 or more, or when the time is more than 600 seconds.
R4A player can join if they are aged 11 or over and 14 or under.
R5A warning shows if the player’s answer is not equal to the correct answer.
R6Even-numbered questions are worth double points.

6. Efa’s test log

Efa wrote these notes while testing. Some are not in correct form.

LineEfa wrote
L1125 / 60 = 2.08 so the display shows 2:08
L2200 DIV 60 = 3 r 20
L3359 s = 5:59 min
L4600 MOD 60 = 10
L5bonus if time =< 10
L695 s = 1 min 35 s