Computer Science (9608) · May/June 2018 · Mark scheme 21

Cambridge Computer Science (9608) mark scheme for paper 21, May/June 2018 — 9608/21/M/J/18, file 9608_s18_ms_21.pdf.

Advertisement
Loading the paper…
Text of this paper

www.dynamicpapers.com

Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE

9608/21

Paper 2 Written Paper

May/June 2018

MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the May/June 2018 series for most
Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and
some Cambridge O Level components.

IGCSE™ is a registered trademark.

This document consists of 14 printed pages.
© UCLES 2018

[Turn over

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Generic Marking Principles

These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level descriptors
for a question. Each question paper and mark scheme will also comply with these marking principles.
GENERIC MARKING PRINCIPLE 1:
Marks must be awarded in line with:
•
•
•

the specific content of the mark scheme or the generic level descriptors for the question
the specific skills defined in the mark scheme or in the generic level descriptors for the question
the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:
Marks awarded are always whole marks (not half marks, or other fractions).
GENERIC MARKING PRINCIPLE 3:
Marks must be awarded positively:
•
•
•
•
•

marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
marks are awarded when candidates clearly demonstrate what they know and can do
marks are not deducted for errors
marks are not deducted for omissions
answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:
Rules must be applied consistently e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.
GENERIC MARKING PRINCIPLE 5:
Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).
GENERIC MARKING PRINCIPLE 6:
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© UCLES 2018

Page 2 of 14

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

9608/21

Question

Answer

1(a)

Marks
Suitable Identifier
Name

Description of Data Item
The temperature of the patient

PatientTemperature

The temperature of the room

RoomTemperature

The patient identification number

PatientID

The name of the nurse taking the
measurement

NurseName

4

The above are examples only.
Names must be meaningful and unambiguous
Items 1 and 2 must have suitable prefix / suffix (i.e. not just 'temp')
1(b)(i)

Expression

Evaluates to

"Mon" & MID(MyGreeting, 10, 2)

"Month"

AgeInYears + ASC(MyInitial)

94

INT(MyInitial)

ERROR

MOD(Weight * 2, 10)

1

Maried AND (NOT Children)

1(b)(ii)

5

FALSE

Variable

Data type

MyGreeting

STRING

MyInitial

CHAR

AgeInYears

INTEGER

Weight

REAL

Married

BOOLEAN

5

One mark per answer
Alternative appropriate data types acceptable

Question

Answer

Marks

2(a)(i)

•
•
•
•

Indentation
Blank lines / white space
Capitalisation of keywords
Meaningful identifier names

4

2(a)(ii)

•

Comments

1

© UCLES 2018

Page 3 of 14

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

Question
2(b)

Answer
Feature
A line containing an example of an assignment statement

Answer
08,12,13,19

A line containing the start of a repetition block

10

A line containing the end of a repetition block

23

The line containing the start of a selection statement

15

The number of parameters of the MID function

3

The boolean operator used

© UCLES 2018

Marks

AND

The number of local variables

4

The number of function calls from within StringClean()
resulting from the call:
NewString ← StringClean("Me")

5

The number of a line containing an unneccessary
statement

06

Page 4 of 14

9

Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D

9608/21
9

Question
Q

Answerr

3

8

One mark for:
1
2
3
4
5
6
7
8

© UCLES 2018

Mark
ks

STAR
RT and END
D / STOP
promp
pt and inputt of Sensor
rID (allow alt
a name)
decision box checking that S
SensorID is
i between 1 & 10
calling
g GetTemp with Senso
orID as parameter
decision box com
mparing Tem
mp > HighT
Temp
calling
g Alarm()
decision box com
mparing Tem
mp < LowTe
emp
both output
o
mess
sages

Page 5 of 14

Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D

9608/21
9

Question
Q
3

Answerr
ALTERNA
ATIVE SOLU
UTION USIN
NG 'CASE'

Mark as fo
ollows:
1
2
3
4
5
6
7
8

© UCLES 2018

One mark
m
for STA
ART and EN
P
ND / STOP
One mark
m
for pro
ompt and inp
put of Sens
sorID (allow
w alt name))
One mark
m
for dec
cision box cchecking tha
at SensorI
ID is betweeen 1 & 10
One mark
m
for calling GetTem
mp with Sen
nsorID as parameter
One mark
m
for dec
cision box C
CASE Temp
p
One mark
m
for calling Alarm ()
One mark
m
for two
o correct CA
ASE conditio
ons
One mark
m
for botth output me
essages

Page 6 of 14

Mark
ks
8

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

9608/21

Question
4(a)

Answer

Marks

Features:
•
•
•

3

The hierarchy of modules
The parameters that are passed between modules // the interface between
the modules
The sequence of module execution

One mark per item
4(b)

6

ItemProcess

InString

InString
RetFlag

RemoveFromList

AddToList

Mark as follows:
One mark for top box
One mark for both lower boxes
One mark for diamond 'decision' symbol
One mark for each parameter (3 parameters)

Question

Answer

5(a)

Details are saved after the program ends // after the computer is switched off

5(b)

Two from the following examples:
•
•
•
•
•
•
•
•

© UCLES 2018

Context-sensitive help
Syntax checking (on entry)
Automatic indentation
Type checking (Parameter checking)
PrettyPrinting
Highlight structure blocks (e.g. selection, iteration)
Highlight any undeclared variables
Highlight any unassigned variables

Page 7 of 14

Marks
1
Max 2

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

9608/21

Question
5(c)

Answer
'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language solutions appear in the Appendix.
PROCEDURE AddNewScores()

DECLARE
DECLARE
DECLARE
DECLARE

FileData : STRING
ScoreDate : STRING
MembershipNumber : STRING
Score : STRING

OUTPUT "Input the date for the scores"
INPUT ScoreDate
OPENFILE "ScoreDetails.txt" FOR APPEND
OUTPUT "Input the Membership number"

INPUT MembershipNumber

WHILE NOT MembershipNumber = ""
OUPUT "Input the score"
INPUT Score

WHILE (INT(SCORE) < 50) OR (INT(SCORE) > 99)
OUTPUT "Input a valid score from 50 to 99"
INPUT Score
ENDWHILE

FileData = MembershipNumber & ScoreDate & Score

WRITEFILE "ScoreDetails.txt", FileData
OUTPUT "Input the Membership number"

INPUT MembershipNumber

ENDWHILE
CLOSEFILE("ScoreDetails.txt")
ENDPROCEDURE
1 mark for each of the following:
1
2
3
4
5
6
7
8
9

© UCLES 2018

Declare MembershipNumber as STRING and Score as INTEGER /
STRING (commented in Python)
Prompt and Input of ScoreDate
Open ScoreDetails.txt in APPEND mode
Prompt and Input of MembershipNumber in a loop
(Outer) loop terminated when MembershipNumber = ""
Input Score and loop until valid
Form the text string from the three variables
Write the text string to the file
Close the file

Page 8 of 14

Marks
9

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

9608/21

Question
6(a)(i)

6(a)(ii)
6(b)

Answer
•
•
•
•

The array is 1D
1 is the lower bound
5 is the upper bound
size of array / number of elements = 5

•

subscript / index

Max2

1

FUNCTION Lighten() RETURNS BOOLEAN
DECLARE OldPixelValue : INTEGER
DECLARE NewPixelValue : INTEGER
DECLARE PixelTemp : REAL
DECLARE BurnFlag : BOOLEAN
DECLARE i : INTEGER
DECLARE j : INTEGER
BurnFlag ← FALSE
FOR i ← 1 TO 8
FOR j ← 1 TO 8

OldPixelValue ← Picture[i, j]
PixelTemp ← OldPixelValue * 1.1
NewPixelValue ← INT(PixelTemp)
IF NewPixelValue >= 255
THEN
NewPixelValue ← 255
BurnFlag ← TRUE
ENDIF
Picture[i, j] ← NewPixelValue
ENDFOR
ENDFOR
RETURN BurnFlag
ENDFUNCTION
1 mark for each of the following:
1
2

Function heading as above and ending
Declare and initialise local variable for return BOOLEAN / other mechanism
to record 'burnt out'
3 Declare local variables for loop counters
4 Correct nested loops
5 Accessing element from array
6 Calculating new value and convert to an INTEGER
7 Comparing new value with 255 and if greater:
8 «limit to 255 and assign to original element
9 «Set flag / other mechanism if limit applied (Only change once)
10 Return a BOOLEAN (following conversion if other mechanism used) MUST
WORK

© UCLES 2018

Marks

Page 9 of 14

MAX8

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

9608/21

Question
7

Answer
'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language solutions appear in the Appendix.
FUNCTION ProcessMarks(Mark: ARRAY[1:20] OF INTEGER)
RETURNS INTEGER
DECLARE Highest : INTEGER
DECLARE Average as REAL
DECLARE Total as INTEGER
DECLARE Position as INTEGER
Total ← 0
Highest ← Mark[1] //The highest mark is the first one
Position ← 1
FOR i ← 1 to 20
Total ← Total + Mark[i]
IF Mark[i] > Highest
THEN
Highest ← Mark[i]
Position ← i
ENDIF
ENDFOR
Average ← Total/20
Output ("The average mark is " & Average & " and the
highest mark is " & Highest)
RETURN Position
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8

Correct Function heading (including Mark as parameter) and ending
Declare local variable for Highest and initialise
Loop structure (1 to 20 or 0 to 19)
Comparison with current Highest
«Assign new Highest
Calculate Average
Output message including both variables and explanatory text
Return value of index

*** End of Mark Scheme – example program code solutions follow ***

© UCLES 2018

Page 10 of 14

Marks
Max7

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

Appendix
Program Code Example Solutions
Q5(c)
Visual Basic
Sub AddNewScores()
Dim
Dim
Dim
Dim
Dim

FileData As String
MembershipNumber As String
Score As Integer
ScoreDate As String
FileHandle As IO.StreamWriter
FileHandle = New IO.StreamWriter("ScoreDetails.txt")
Console.WriteLine("Input the date for the scores")
ScoreDate = Console.ReadLine()
Console.WriteLine("Input the Membership number")
MembershipNumber = Console.ReadLine()
Do While MembershipNumber <> ""
Console.WriteLine("Input the score")
Score = Console.ReadLine()
Do While Score < 50 Or Score > 99
Console.WriteLine("Input a valid score from 50 to 99")
Score = Console.ReadLine()
Loop
FileData = MembershipNumber & ScoreDate & Str(Score)
FileHandle.WriteLine(FileData)
Console.WriteLine("Input the Membership number")
MembershipNumber = Console.ReadLine()
Loop
FileHandle.Close()

End Sub

© UCLES 2018

Page 11 of 14

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

Python
def AddNewScores():
#ScoreDate as string
#MembershipNumber as string
#Score as integer
#FileHandle as text file
FileHandle = open("ScoreDetails.txt", "a")
ScoreDate = str(input("Input the date for the scores"))
MembershipNumber = str(input("Input the Membership number"))
while MembershipNumber != "":
Score = int(input("Input the score"))
while Score < 50 or Score > 99:
Score = int(input("Input a valid score from 50 to 99"))
FileData = MembershipNumber + ScoreDate + str(Score)
FileHandle.write(FileData)
MembershipNumber = str(input("Input the Membership number"))
FileHandle.close

Pascal
procedure AddNewScores;
var FileData, ScoreDate, MembershipNumber: String;
Score: Integer
MyFile: text;
begin
assign(MyFile,'ScoreDetails.txt');
append(MyFile);
writeln('Input the date for the scores');
readln(ScoreDate);
writeln('Input the Membership number');
readln(MembershipNumber);
while MembershipNumber <> '' do
begin
writeln('Input the score');
readln(Score);
while (Score < 50) or (Score > 99) do
begin
writeln('Input the score');
readln(Score);
end;
FileData := MembershipNumber + ScoreDate + IntToStr(Score);
write(MyFile, FileData);
writeln('Input the Membership number');
readln(MembershipNumber);
end;
close (MyFile);
end;

© UCLES 2018

Page 12 of 14

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

Q7
Visual Basic
Function ProcessMarks(ByVal Mark() As Integer) As Integer
Dim
Dim
Dim
Dim
Dim

Highest As Integer
Average As Single
Total As Integer
Position As Integer
i As Integer

Total = 0
Position = 1
Highest = Mark(1)
For i = 1 To 20
Total = Total + Mark(i)
If Mark(i) > Highest Then
Highest = Mark(i)
Position = i
End If
Next
Average = Total / 20
Console.WriteLine ("The average mark is " & Average & _
" and the highest mark is " & Highest)
Return Position
End Function
Python
def ProcessMarks (mark):
#highest, i, position, total as integer
#average as real
highest = mark[0]
total = 0
position = 0
for i in range(0,20):
total = total + mark[i]
if mark[i] > highest:
highest = mark[i]
position = i
average = total/20
print('The average mark is ' + str(average) + \
' and the highest mark is ' + str(highest))
return position

© UCLES 2018

Page 13 of 14

9608/21

Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED

Pascal
function ProcessMarks (mark:array of integer):integer;
var highest, total, position, i: integer;
average: real;
begin
highest := mark[1];
total := 0;
position := mark[1];
for i := 1 to 20 do
begin
total := total + mark[1];
if mark[i] > highest then
begin
highest := mark[i];
position := i;
end;
end;
average := total / 20;
writeln ('The average mark is ', average, ' and the highest mark is ',
highest);
ProcessMarks := position;
end;

© UCLES 2018

Page 14 of 14

Advertisement