Cambridge AS Level Computer Science 9618 · 12.2 Program Design

Q16 · 9618/22/O/N/22 Q2

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

Q169618/22/O/N/22original Q2Structured · 11 marks
Question 2 from 9618/22/O/N/22

Worked solution

(a)(i)

Write the steps in words, in order:

Open Support_List.txt in APPEND mode (and close it at the end) [1]

Prompt for and input a student name and mark [1]

If the mark is 20 or more, skip to the repeat step [1]

If the mark is less than 20, write only the name to the file [1]

Repeat for all 35 students [1]

(a)(ii)

The data in a file is saved permanently, even after the computer is switched off, so it does not need to be typed in again when the program is re-run. [1]

(a)(iii)

WRITE mode would overwrite the existing data in the file, so the names from the other group tests would be lost. [1]

(b)

Follow the arrows from each state. From S1, Input-A gives Output-X and goes to S2. At S2, Input-A loops back to S2 with no output. S2 with Input-B gives Output-W and goes to S3. S3 with Input-A gives Output-W and goes to S4.

InputOutputNext state
S1
Input-AOutput-XS2
Input-A(none)S2
Input-BOutput-WS3
Input-AOutput-WS4

Row 2 correct [1]

Row 3 correct [1]

Row 4 correct [1]

Row 5 correct [1]

KEY IDEAAPPEND adds to a file without losing what is there, and a file keeps its data when the power is off.
TOTAL 11 marks

Official mark scheme

Mark scheme for 9618/22/O/N/22 question 2
VIDEO
▶ Whole paper

Video solution of the whole paper · by Audere Prep. 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.