Computer Science (9608) · Oct/Nov 2016 · Mark scheme 21
Cambridge Computer Science (9608) mark scheme for paper 21, Oct/Nov 2016 — 9608/21/O/N/16, file 9608_w16_ms_21.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/21
Paper 2 Written Paper
October/November 2016
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 will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the October/November 2016 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
® IGCSE is the registered trademark of Cambridge International Examinations.
This document consists of 13 printed pages.
© UCLES 2016
[Turn over
Page 2
1
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
(a)
2
Yes
12
Note: Order of 11, 10
and 7,8 may be
reversed.
No
11
7
10
8
6
Yes
4
No
1
3
9
© UCLES 2016
Syllabus
9608
Paper
21
www.dynamicpapers.com
Page 3
Mark Sc
cheme
C
Cambridge
e International AS/A L
Level – October/November 20166
One
e mark for each
e
of the following syymbols / sy
ymbol combinations:
• 2
• 7 and 8 fro
om YES
• 10 and 11
• 6
• 1 and 3 (1 from NO, 3 from YES
S)
• 9
• 12 and 4
Syllabus
s
9608
Paper
21
Max [6
6]
(b) Row
ws 2 to 7 are
a example
es only
Expec
cted
outputt
TicketType
BaggageW
Weight
Exxplanation
E
15
U nder the
al lowance
E
> 16
U nder the
al lowance
Charg
ge
S
<= 20
U nder the
al lowance
0
S
> 20
U nder the
al lowance
Charg
ge
E
16
S
20
Eo
or S
negative or
o nonnumeric
Bo
oundary
eight for a
we
tyype E ticket
Bo
oundary
eight for a
we
tyype S ticket
nvalid weigh
ht
In
0
0
0
Error message
m
One mark for each different test (e
examples above)
a
© UCLES 201
16
Max [5
5]
Page 4
www.dynamicpapers.com
Mark Sc
cheme
C
Cambridge
e International AS/A L
Level – October/November 20166
Syllabus
s
9608
Paper
21
(c) INP
PUT Ticke
etType
WHI
ILE NOT (TicketTy
ype = 'E' ) OR (TicketType = 'S')
icketType
e
INPUT Ti
END
DWHILE
One
e mark for each
e
of:
• WHILE ... ENDWHI
ILE
• Correct co
ondition in a loop
• INPUT witthin loop plu
us one befo
ore loop // alternative
a
arrangemen
a
nt leading to
o correct exxit
from loop
[3
3]
2
(a)
St
tatus2
R
ReadingCo
ount
T
ThisBit
BitCou
unt
O
OUTPUT
0
1
1 must 'follo
ow' 6 as
shown by a
arrow. Can
have only 1 or nothing
above.
1
1
1
2
0
1
3
1
2
4
1
3
5
1
4
6
0
4
1
1
5
1
E
Error –
Invvestigate
0
0 must 'fo
ollow' 6 as
shown byy arrow. Can
n
have onlyy 1 or nothing
above.
2
1
1
3
0
1
4
0
1
5
1
2
6
1
3
0
One
e mark per area outline
ed
[7
7]
© UCLES 201
16
Page 5
3
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
Paper
21
(b) One mark for each of:
• Assignment: 01 // 02 // 06 // 09 // 14 // 18
• Selection: 07 // 11
• Iteration: 03 // 05
[3]
(a) (i) 7
[1]
(ii) 103
[1]
(iii) 'K'
[1]
(iv) "come"
[1]
(b) (i) PROCEDURE CalculateCustomerID
OUTPUT "Key in surname"
INPUT Surname
Length ← CHARACTERCOUNT(Surname)
CustomerID ← 0
FOR i ← 1 TO Length
//NextChar is a single character from Surname
Nextchar ← 1 SUBSTR(Surname, i, 1) // ONECHAR(Surname, i)
NextCodeNumer ← ASC(NextChar)
CustomerID ← CustomerID + NextCodeNumber
ENDFOR
OUTPUT "Customer ID is ", CustomerID
ENDPROCEDURE
One mark per phrase in bold
[3]
© UCLES 2016
Page 6
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
Paper
21
(ii) 'Pseudocode' solution included here for development and clarification of mark scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE CalculateCustomerID
DECLARE Surname : STRING
DECLARE NextChar : CHAR
DECLARE NextCodeNumber, i, CustomerID, SLength : INTEGER
OUTPUT "Key in surname"
INPUT Surname
SLength ← LEN(Surname)
CustomerID ← 0
FOR i ← 1 TO SLength
//NextChar is a single character from Surname
Nextchar ← MID(Surname, i, 1)
NextCodeNumber ← ASC(NextChar)
CustomerID ← CustomerID + NextCodeNumber
ENDFOR
OUTPUT "Customer ID is ", CustomerID
ENDPROCEDURE
Mark as follows:
• Declaration of Surname as STRING and NextChar as CHAR and any three
INTEGERs
• Prompt and Input
• Calculation of string length
• FOR Loop to process all characters in the string
• Assignment to NextChar in a loop
• Assignment to NextCodeNumber in a loop
• Totalling CustomerID in a loop
• Output following a loop
[6]
(c) (i) Visual Basic
Function CalculateCustomerID(ByVal AnyName AS STRING) As Integer
Pascal
FUNCTION CalculateCustomerID(AnyName : STRING) : INTEGER
Python
def CalculateCustomerID(AnyName):
Mark as follows:
• Correct keyword + Function name
• Single input parameter of correct type
• Return parameter type
[3]
(ii) Visual Basic
Return customerID // CalculateCustomerID = CustomerID
Pascal
Result := CustomerID // CalculateCustomerID := CustomerID
Python
Return CustomerID
[1]
© UCLES 2016
www.dynamicpapers.com
Page 7
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
Paper
21
(iii) Visual Basic
ThisID = CalculateCustomerID ("Wilkes")
Pascal
ThisID := CalculateCustomerID ('Wilkes')
Python
ThisID = CalculateCustomerID ("Wilkes")
One mark per underlined element
(d) (i) •
•
•
•
•
(ii) •
•
•
•
•
•
4
(a) •
•
•
Built-in functions are made available by the programming language / already in the
system
Built-in functions are ready made and tested
User-defined functions can be modified // built-in cannot be modified
User defined functions can be designed to meet the user's requirements
User-defined functions can only be used in that program / module
[Max 2]
They have an identifier name
They return a value
They have none, one or more arguments
Both perform a specific task
Both represent re-usable code
Both are 'called'
Create / modify the source code using the text editor
Compiler translates the source code
Compiler produces the object code
(b) (i) •
•
•
•
•
•
•
•
•
(ii) •
•
•
[3]
[Max 2]
[Max 3]
Errors in keywords are highlighted // before the compilation process
Provides line-by-line syntax checking as code is typed in
Provides line number of the error
Display of known identifier names
Auto-complete
Colour-coding
Auto-indent
type checking
Subroutine parameter checking
[Max 1]
Set break-points
Single step / step into/over subroutine
Window to watch the changing value of variables
[Max 1]
© UCLES 2016
Page 8
www.dynamicpapers.com
cheme
Mark Sc
C
Cambridge
e International AS/A L
Level – October/November 20166
Syllabus
s
9608
Paper
21
(c) (i) OPEN "PR
RODUCTS" FOR READ
D
i ← 1
OT EOF("P
PRODUCTS"
")
WHILE NO
READFILE ("PR
RODUCTS",
, PCode[i
i])
RODUCTS",
, PDescri
iption[i])
READFILE ("PR
RODUCTS",
, Temp //
/ PRetail
lPrice[i] )
READFILE ("PR
[i] ← TO
ONUM(Temp
p)
PRetailPrice[
i ← i + 1
E
ENDWHILE
CLOSE "P
PRODUCTS"
"
OUTPUT "Product
"
ntents wr
ritten to arrays"
file con
One markk per bold ph
hrase (three
e READFILE() counts as
a a single mark)
[5
5]
(ii) Benefit:
• The number
n
of file read ope
erations is re
educed (by 2/3rds)
• It mayy use less storage
s
/ sp ace in the file
f if strings
s are NOT fiixed length
• All the
e data relate
ed to a sing
gle product is read at once / in onee file operattion /
group
ped together
Drawbackk:
• The program
p
will need to usse the string
g handling functions to isolate eac
ch of the
three items of da
ata
• Difficu
ult to isolate
e data itemss if the form
mat is not consistent
• More difficult to search
s
b
and one drawba
ack
Max one benefit
© UCLES 201
16
[2
2]
Page 9
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
Paper
21
(d)
A
D
B
C
One mark per group (one or more names) as follows:
A: SearchCode
B: SearchCode // ThisIndex
C: ThisRetailPrice, ThisDescription
D: SearchCode, ThisDescription, ThisRetailPrice
© UCLES 2016
[4]
Page 10
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
Paper
21
(e) 'Pseudocode' solution included here for development and clarification of mark scheme.
Programming language example solutions appear in the Appendix.
FUNCTION ProductCodeSearch(AnyName : String) RETURNS : Integer
DECLARE FoundPos : Integer
DECLARE i : Integer
i ← 1
FoundPos ← -1
REPEAT
IF AnyName = PCode[i]
THEN
FoundPos ← i
ELSE
i ← i + 1
ENDIF
UNTIL (i = 1001) OR (FoundPos <> -1)
RETURN FoundPos
ENDFUNCTION
Mark as follows:
• Function header returns INTEGER
• Initialisation of index variable
• Loop through array PCode (including exit when found)
• Comparison of AnyName with PCode[i] in a loop
• Increment index variable in a loop
• Return index if AnyName found AND return -1 if AnyName not found
5
[Max 6]
(i) 13 / 13.0
[1]
(ii) 18.6
[1]
(iii) TRUE
[1]
(iv) 32
[1]
(v) 22
[1]
*** End of Mark Scheme – Example program code solutions follow ***
© UCLES 2016
Page 11
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Appendix – Example program code solutions
3(b)(ii): Visual Basic
Dim
Dim
Dim
Dim
Dim
Dim
Surname As String
NextChar As Char
NextCodeNumber As Integer
i As Integer
CustomerID As Integer
SLength As Integer
Console.Write("Key in surname ")
Surname = Console.ReadLine
SLength = Len(Surname)
CustomerID = 0
For i = 1 To SLength
\\ NextChar is a single character from surname
NextChar = Mid(Surname, i, 1)
NextCodeNumber = Asc(NextChar)
CustomerID = CustomerID + NextCodeNumber
Next
Console.WriteLine("Customer ID is " & CustomerID)
3(b)(ii): Pascal
Var Surname : string;
SLength, i, CustomerID, NextCodeNumber : integer;
NextChar : char;
begin
Writeln ('Enter the surname: ');
Readln (Surname);
SLength := Length(Surname);
CustomerID := 0;
For i := 1 to SLength do
begin
NextChar := SurName[i];
NextCodeNumber := Ord(NextChar);
CustomerID := CustomerID + NextCodeNumber;
end;
Writeln ('Customer ID is ', CustomerID);
Readln;
end.
© UCLES 2016
Syllabus
9608
Paper
21
Page 12
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
Syllabus
9608
3(b)(ii): Python
# Surname String
# NextChar Char
# NextCodeNumber, I, CustomerID, SLength Integer
Surname = input("Key in Surname ")
SLength = len(Surname)
CustomerID = 0
for i in range(SLength):
# NextChar is a single character from surname
NextChar = Surname[i]
NextCodeNumber = ord(NextChar)
CustomerID = CustomerID + NextCodeNumber
print("Customer ID is " + str(CustomerID))
4(e): Visual Basic
Function ProductCodeSearch(ByVal SearchCode As String) As Integer
Dim FoundCode As Integer
Dim i As Integer
i = 1
FoundCode = -1
Do
If SearchCode = PCode(i) Then
FoundCode = i
Else
i = i + 1
End If
Loop Until i = 1001 Or FoundCode <> -1
Return FoundCode
End Function
© UCLES 2016
Paper
21
Page 13
www.dynamicpapers.com
Mark Scheme
Cambridge International AS/A Level – October/November 2016
4(e): Pascal
Function ProductCodeSearch (SearchCode : String): integer;
var FoundCode, ThisIndex : integer;
Found : Boolean;
Begin
Found := false;
ThisIndex := 1;
Repeat
If SearchCode = PCode[ThisIndex] then
Begin
FoundCode := ThisIndex;
Found := true;
Else
ThisIndex := ThisIndex + 1;
end;
Until (ThisIndex = 1001) OR (Found);
If Found = false then
FoundCode := -1
ProductCodeSearch := FoundCode;
end.
4(e): Python
def ProductCodeSearch(SearchCode):
# list indexes start at zero
i = 0
Found = "no"
while not(i == 1001 or Found == "yes"):
if SearchCode == PCode[i]:
Found = "yes"
FoundIndex = i
else:
i = i + 1
if Found == "no":
FoundIndex = -1
return FoundIndex
© UCLES 2016
Syllabus
9608
Paper
21