Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics

Q13 · 9618/23/M/J/23 Q2

Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3.

Q139618/23/M/J/23original Q2Structured · 6 marks
Question 2 from 9618/23/M/J/23

Worked solution

(a)

Use the DAYINDEX() function. Sunday is 1, so Thursday is 5.

Write: IF DAYINDEX(MyDOB) ... THEN (the function applied to MyDOB) [1]

Write: ... = 5 (the comparison with 5) [1]

(b)(i)

Write the two checks that need only one parameter each:

Check the month is between 1 and 12 (inclusive) [1]

Check the year is 2002 or earlier (so the student is at least 18 in 2020) [1]

(b)(ii)

The day depends on the month.

Write: the check uses the month and the day together [1]

Write: the day must be possible for that month, for example no day 31 in a 30-day month (and a month-based limit for February) [1]

KEY IDEASome checks need one value only (a range), while others need a second value (day depends on month).
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/23/M/J/23 question 2
VIDEO
▶ Starts at Q2 (21:00)

Starts at Q2 (21:00) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.