Computer Science (9608) · May/June 2018 · Mark scheme 22
Cambridge Computer Science (9608) mark scheme for paper 22, May/June 2018 — 9608/22/M/J/18, file 9608_s18_ms_22.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/22
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 16 printed pages.
© UCLES 2018
[Turn over
9608/22
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 16
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
Answer
Marks
1(a)
4
Description of data item
Suitable identifier name
The temperature inside the greenhouse
GreenhouseTemperature
The temperature outside the greenhouse
OutsideTemperature
The greenhouse identification number
GreenhouseID
The time the temperature was measured
SampleTime
The above are examples only.
Names must be meaningful and unambiguous
1(b)(i)
5
Expression
Evaluates to
"Fas" & MID(Subject, 6, 3)
"Faster"
LEFT(Mark, 1)
ERROR
10 + ASC(Grade)
76
MOD(AverageMark * 2, 3)
0
CourseCompleted AND (Mark >= 60)
TRUE
1(b)(ii)
5
Variable
Data type
Mark
INTEGER
Subject
STRING
Grade
CHAR
CourseCompleted
BOOLEAN
AverageMark
REAL
One mark per answer
© UCLES 2018
Page 3 of 16
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
Answer
2(a)(i)
•
•
•
•
Keywords in capitals
White Space / blank lines / grouping
Comments
Sensible function names
2(a)(ii)
•
•
Indentation
Meaningful identifier names
Marks
Max 2
2
2(b)
8
Feature
Answer
A line number containing an example of an
assignment statement
08 / 09 / 13 / 14 / 15 /
21
A line number containing the start of a ‘precondition’ loop
11
A line number containing the end of a ‘precondition’ loop
24
A line number containing the start of a
selection statement
17
The number of parameters of the LEFT()
function
2
The Boolean operator used
OR
The number of times the function LEFT() is
called from within CountDigits() resulting
6
from the call:
Result ← CountDigits("AB27C4")
The number of local variables
2(c)(i)
•
•
© UCLES 2018
3
Mistake: function header returns a CHAR but last line of code returns an
INTEGER
Correction: Function should return an INTEGER // Change line 26 to
return c as CHAR
Page 4 of 16
2
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Question
Answer
2(c)(ii)
4
IF (nc >= '0') AND (nc <= '9')
THEN
c ← c + 1
ENDIF
One mark for each of:
• Single IF THEN ENDIF statement (no ELSE)
• Switching OR to AND
• Lower value comparison
• Upper value comparison
ALTERNATIVE:
IF NOT ((nc < '0') OR (nc > '9'))
THEN
c ← c + 1
ENDIF
One mark for each of:
• Single IF THEN ENDIF statement (no ELSE)
• Inverting test using NOT«
• ... correct use of brackets
• « both comparisons unchanged
© UCLES 2018
Marks
Page 5 of 16
9608/22
9
Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D
Question
Q
3
© UCLES 2018
Answer
Example Program
P
Flo
owchart
Marks
10
Page 6 of 16
Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D
9608/22
9
Question
Q
3
Answer
One markk for each off:
Marks
10
1
2
3
4
5
6
7
8
9
STAR
RT and END
D / STOP
Initialising Count
t to 0
Initialising Index
x to 1 or 0
Decission box com
mparing Ba rWeight[Index] > MaxWeight
M
t
Decission box com
mparing In dex to 100
Decission box com
mparing Co unt > Thre
eshold
Corre
ect incremen
nt of Index
x
Corre
ect incremen
nt of Count
t
Outpu
ut message
e (concatena
ation of textt and value)) if thresholdd not
excee
eded
10 Callin
ng ServiceCheck() if Thresho
old exceeded (withoutt text
message)
Question
Q
Answer
4(a)(i)
2
ollows:
Mark as fo
•
•
© UCLES 2018
Marks
One mark
m
for thrree arrows a
all labelled X (with filled
d circles)
One mark
m
for dia
amond symb
bol
Page 7 of 16
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
Answer
4(a)(ii)
Marks
3
Parameter
A
Information
BasketID
B
C
BasketID, ItemID, Quantity
(In any order)
D
E
F
BasketID, DeliveryAddress, PaymentDetails
(In any order)
G
Mark as follows:
•
•
•
One mark for parameter A
One mark for parameters B, C & D
One mark for parameters E, F & G
Question
5(a)
Answer
One mark for each of:
•
•
•
•
5(b)
© UCLES 2018
Max 2
Same data type using a single identifier / more efficient coding / less
declaration statements needed
Access of individual elements (using subscript / index)
Ability to iterate through the data // easier to search / sort the data
Code easier to understand / maintain / modify
One mark for each of:
•
•
•
•
Marks
Max 2
(Dynamic) syntax checking / Errors are highlighted / underlined
Type checking
Parameter checking
Identification of unused variables
Page 8 of 16
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
5(c)
Answer
Example ‘Pseudocode’ solution included here for development and
clarification of mark scheme.
Programming language example solutions appear in the Appendix.
FUNCTION GetNumber() AS STRING
DECLARE Valid : BOOLEAN
DECLARE MemberNumber : INTEGER
REPEAT
Valid ← TRUE
OUTPUT "Please input a valid member number"
INPUT MemberNumber
IF (MemberNumber > 9999) OR (MemberNumber < 1111)
THEN
Valid ← FALSE
ENDIF
UNTIL Valid = TRUE
RETURN STR(MemberNumber)
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
© UCLES 2018
Function heading (as above) and ending
Conditional loop structure
Condition to check valid membership number
Returning string value
Page 9 of 16
Marks
4
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
5(d)
Answer
‘Pseudocode’ solution included here for development and clarification of
mark scheme.
Programming language solutions appear in the Appendix.
PROCEDURE
DECLARE
DECLARE
DECLARE
OutputLowestScore()
FileData, FileMembershipNumber : STRING
FileScore, LowestScore : INTEGER
LowestScoreDate, MembershipNumber : STRING
MembershipNumber ← GetNumber()
OPENFILE "ScoreDetails.txt" FOR READ
LowestScore ← 100
WHILE NOT EOF("ScoreDetails.txt")
READFILE "ScoreDetails.txt", FileData
FileMembershipNumber ← LEFT(FileData, 4)
IF FileMembershipNumber = MembershipNumber
THEN
FileScore ← INT(RIGHT(FileData,2))
IF FileScore < LowestScore
THEN
LowestScore ← FileScore
LowestScoreDate ← MID(FileData(5,6))
ENDIF
ENDIF
ENDWHILE
OUTPUT ("The lowest score was " & LowestScore & " on "
& _
LowestScoreDate)
CLOSEFILE("ScoreDetails.txt ")
ENDPROCEDURE
1 mark for each of the following:
1
Declare variables to store LowestScore as INTEGER and FileData
as STRING (commented in Python) (variable names may be different)
2 Function call GetNumber() for membership number
3 Initialisation of LowestScore to 99 or above
4 Open file in READ mode
5 Loop until EOF()
6 Read a line from the file in a loop
7 Use of substring operations to extract at least one data item
8 Compare the membership numbers
9 Convert score to INTEGER
10 Compare and assign (if appropriate) new value to LowestScore
11 Output the lowest score message including lowest score and date
(outside the loop)
12 Close the file
© UCLES 2018
Page 10 of 16
Marks
Max 10
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
Answer
6(a)
•
•
6(b)
Example using single temp variable:
2
lower bound
upper bound
PROCEDURE Flip()
//Use of Single temp value
DECLARE temp : INTEGER
DECLARE i : INTEGER //i is the row
DECLARE j : INTEGER //j is the column
FOR i ← 1 TO 5
FOR j ← 1 to 4 //swap element 1&8, 2&7, 3&6, 4&5
temp ← Picture[i,j]
Picture[i,j] ← Picture[i, 9 - j]
Picture[i, 9 - j] ← temp
ENDFOR
ENDFOR
ENDPROCEDURE
Alternative Solution – Use of temp array row:
PROCEDURE Flip()
//Use of temproary row (8 elements)
DECLARE temp : ARRAY[1:8] OF INTEGER
DECLARE i : INTEGER //i is the row
DECLARE j : INTEGER //j is the column
FOR i ← 1 to 5
FOR j ← 1 to 8
temp[j] ← Picture[i, 9 – j] //temp is row i
reversed
ENDFOR
FOR j ← 1 to 8
Picture[i,j] ← temp[j] //copy temp back to row i
ENDFOR
ENDFOR
ENDPROCEDURE
© UCLES 2018
Marks
Page 11 of 16
8
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/22
Question
6(b)
Answer
Alternative Solution – Use of new array:
PROCEDURE Flip()
//Flip to New array
DECLARE NewPic : ARRAY[1:5, 1:8] OF INTEGER
DECLARE i : INTEGER //i is the row
DECLARE j : INTEGER //j is the column
FOR i ← 1 to 5
FOR j ← 1 to 8
NewPic[i, 9 - j] ← Picture[i, j] //NewPic row
is Pic row flipped
ENDFOR
ENDFOR
END PROCEDURE
1 mark for each of the following (all methods):
1
2
3
4
5
6
7
8
Correct procedure heading and ending
Declaring local variables for loop counter(s)
Declaring a temporary storage variable for swap or new duplicate 2D
array
A nested loop including attempt at flip operation «
« Correct number of iterations
Assign element to temp (single var or temp array) or to new array
Selection of correct source element (row, column)
Selection of correct destination element (row, column)
*** End of Mark Scheme – program code solutions follow ***
© UCLES 2018
Page 12 of 16
Marks
8
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Appendix
Program Code Example Solutions
Q5 (c): Visual Basic
Function GetNumber() As String
Dim Valid As Boolean
Dim MemberNumber As Integer
Do
Valid = True
Console.Write("Please enter a valid member number: ")
MemberNumber = Console.ReadLine()
If MemberNumber > 9999 Or MemberNumber < 1111 Then
Valid = False
End If
Loop Until Valid = True
Return MemberNumber.ToString()
End Function
Q5 (c): Pascal
function GetNumber() : string;
var
Valid : boolean;
MemberNumber : integer;
begin
repeat
Valid := true;
write('Please enter a valid member number: ');
readln(MemberNumber);
if (MemberNumber > 9999) or (MemberNumber < 1111) then
Valid := false;
until Valid = true;
GetNumber := IntToStr(MemberNumber);
end;
Q5 (c): Python
def GetNumber() :
# Valid : boolean
# MemberNumber : integer
Valid = False
while not Valid :
Valid = True
MemberNumber = int(input("Please enter a valid member number: "))
if MemberNumber > 9999 or MemberNumber < 1111 :
Valid = False
return str(MemberNumber)
© UCLES 2018
Page 13 of 16
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Q5 (d): Visual Basic
Sub OutputLowestScore()
Dim FileData As String
Dim FileMembershipNumber As String
Dim FileScore As Integer
Dim LowestScore As Integer
Dim LowestScoreDate As String
Dim MembershipNumber As String
MembershipNumber = GetNumber()
FileOpen(1, "ScoreDetails.txt", OpenMode.Input)
LowestScore = 100
While Not EOF(1)
FileData = LineInput(1)
FileMembershipNumber = Left(FileData, 4)
If FileMembershipNumber = MembershipNumber Then
FileScore = Integer.Parse(Right(FileData, 2))
If FileScore < LowestScore Then
LowestScore = FileScore
LowestScoreDate = Mid(FileData, 5, 6)
End If
End If
End While
Console.WriteLine("The lowest score was " & LowestScore & " on " &
LowestScoreDate)
FileClose(1)
End Sub
© UCLES 2018
Page 14 of 16
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Q5 (d): Pascal
procedure OutputLowestScore();
var
FileData : string;
FileMembershipNumber : string;
FileScore : integer;
LowestScore : integer;
LowestScoreDate : string;
MembershipNumber : string;
Scores : textFile;
begin
MembershipNumber := GetNumber();
assignFile(Scores, 'ScoreDetails.txt');
reset(Scores);
LowestScore := 100;
while not eof(Scores) do
begin
readln(Scores, FileData);
FileMembershipNumber := copy(FileData, 1, 4);
if FileMembershipNumber = MembershipNumber then
begin
FileScore:= StrToInt(copy(FileData, 11, 2));
if FileScore < LowestScore then
begin
LowestScore := FileScore;
LowestScoreDate := copy(FileData, 5, 6)
end;
end;
end;
writeln('The lowest score was ', LowestScore, ' on ', LowestScoreDate);
close(Scores);
end;
© UCLES 2018
Page 15 of 16
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Q5 (d): Python
def OutputLowestScore() :
# FileData : string
# FileMembershipNumber : string
# FileScore : integer
# LowestScore : integer
# LowestScoreDate : string
# MembershipNumber : string
# File : file handle
MembershipNumber = GetNumber()
File = open("ScoreDetails.txt", "r")
LowestScore = 100
FileData = File.readline()
while FileData != "":
FileMembershipNumber = FileData[:4]
if FileMembershipNumber == MembershipNumber :
FileScore = int(FileData[10:12])
if FileScore < LowestScore :
LowestScore = FileScore
LowestScoreDate = FileData[4:10
FileData = File.readline()
print("The lowest score was ", LowestScore, " on ", LowestScoreDate)
File.close()
© UCLES 2018
Page 16 of 16