Computer Science (9608) · May/June 2016 · Mark scheme 22

Cambridge Computer Science (9608) mark scheme for paper 22, May/June 2016 — 9608/22/M/J/16, file 9608_s16_ms_22.pdf.

Advertisement
Loading the paper…
Text of this paper

www.dynamicpapers.com

Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE

9608/22

Paper 2 Written Paper

May/June 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 May/June 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 14 printed pages.
© UCLES 2016

[Turn over

www.dynamicpapers.com
Page 2

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Question
1

(a) (i)

Syllabus
9608

Paper
22

Answer
Item

Statement

Marks
Selection

Iteration

Assignment

6



1

MyScore = 65

2

FOR IndexVal = 0 TO 99

3

MyArray[3] = ID(MyString,3,2)

4

IF MyScore >= 70 THEN

5

ENDWHILE

6

ELSE Message = "Error"









One mark per row
Additional ticks in any row cancels that row
(ii)

Item

6

Purpose of statement

1

Assign 65 to MyScore

2

(Start of) loop with loop counter starting from zero & going to 99 /
repeating 100 times

3

Assign 2 chars from position 3/4 in MyString to MyArray element 3/4

4

Test if MyScore is greater than or equal to 70

5

Marks the end of WHILE / precondition loop //Return to top of loop to
check condition

6

If a condition is FALSE, variable Message is assigned the value "ERROR"

Exact wording not important
Explanation must refer to variables or values used in code (except for row 5)
(iii)

Expression

Result

"D" & RIGHT(MyString, 4)

"Dance"

LEFT(RIGHT(MyString, 7), 3)

"ten"

Must have correct case
Quotation marks optional

© Cambridge International Examinations 2016

2

www.dynamicpapers.com
Page 3

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Question
2

(a)

Syllabus
9608

Paper
22

Answer
Identifier

Data Type

Marks
Description

AlarmState

BOOLEAN

Alarm is set to ON or OFF

SensorValue

INTEGER

Value / number from sensor / as
input by user // used in calculation
of Temperature

ThresholdValue

REAL / FLOAT /
SINGLE / DOUBLE

Threshold value for comparison

Temperature

REAL / FLOAT /
SINGLE / DOUBLE

Temperature value calculated
from sensor value

One mark per row
Data types as shown
Descriptions given above are examples only

© Cambridge International Examinations 2016

4

www.dynamicpapers.com
Pag
P ge 4

Mar
M k Sch
S hem
me
e
C mb
Cam
brid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16

Qu
Q
ues
stio
on

Sylllab
S
bus
9 08
960

Pape
P
er
2
22

An
nsw
wer

(b)
A rm
Ala
mState

←

Mar
M rks
s
Max
M x6

FA
ALS
SE

1

INPUT ThresholdValue
2

INPUT SensorV
Value
Tem
mperature

←

Sen
S nso
orV
Val
lue
e * 1.1
1 135
5

3

IF Temperature > ThresholdValue
HEN
N
TH
lar
rmS
Sta
ate
e
Al

←

T
TRU
UE

5

OU
UTP
PUT
T "Te
" emp
per
rat
tur
re Al
lar
rm"
"
4

LSE
E
EL
OU
UTP
PUT
T "Te
" emp
per
rat
tur
re OK
K"
Al
lar
rmS
Sta
ate
e

←

FA
ALS
SE

6

7

ENDIF

Mark
k poin
p nts ass ciirclled
d, des
d scriptions as
a below
w:
1.
2.
3.
4.
5.
6.
7.

Se
ettin
ng Al
lar
rmS
State tto FA
F LSE (Co
( ond
d. che
c eck
k not essentia
al b
butt mus
m st be
b ccorrrect if
pre
ese
entt)
Inp
puttting S
Sen
nsor
rVa
al an
nd Th
hre
esh
hol
ldVa
al
Co
orre
ectt va
alue
e ass
a sign
ned
d to
o Tem
T mpe
eratur
re (m
( ustt be * not x)
IF
F..
.TH
HEN
N..ELS
SE.
..E
END
DIF stru
s uctture
e with
w h co
orrrec
ct condition
n (o
or two
t o se
epara
ate
e IF
F
cla
aus
ses
s)
Co
orre
ectt TH
HEN
N sta
ateme
entts as
a sho
s ow
wn
Co
orre
ectt EL
LSE
E stat
s tem
ment as sh
how
wn
Se
ettin
ng Al
lar
rmS
State tto FA
F LSE wit
w thin
n ELS
SE cla
c aus
se on
o ly if m
ma
ark po
oin
nt 1 not
giv
ven
n

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6

www.dynamicpapers.com
Page 5

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Question
3

(a)

Syllabus
9608

Paper
22

Answer
FUNCTION EncryptString (LookUp : ARRAY, PlainText : STRING)
RETURNS STRING

Marks
10

DECLARE OldChar, NewChar : CHAR
DECLARE OldCharValue : INTEGER
DECLARE OutString: STRING
//first initialise the return string
OutString ← ""

//initialise the return string

//loop through PlainText to produce OutString
FOR n ← 1 to LENGTH(PlainText)
//from first to last character
OldChar ← MID(PlainText, n, 1)
//get next character
OldCharValue ← ASC(OldChar) //find the ASCII value
NewChar ← Lookup[OldCharValue]
//look up substitute character
OutString ← Outstring & NewChar // concatenate to OutString
ENDFOR
RETURN OutString // EncryptString ← OutString
ENDFUNCTION
One mark for each part-statement (shown underlined and bold)
(b) (i)

VB:

Dim Lookup(0 to 127 / 128) As CHAR

Pascal:

Var Lookup: Array[0..127 / 1..128] Of CHAR

Python: Lookup = ["" for i in range(128)]
OR
Lookup = []
For i in range(128) :
Lookup.append("")
Mark as follows:
VB / Pascal: one mark per part-statement as underlined and bold
Python:
One mark for Lookup and []
One mark for range(128)

© Cambridge International Examinations 2016

2

www.dynamicpapers.com
Pag
P ge 6

Mar
M k Sch
S hem
me
e
C mb
Cam
brid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16

Ques
Qu
stio
on
(ii)

Sylllab
S
bus
9 08
960

An
nsw
wer

Mar
M rks
s

'P
Pseudocode' ssollutiion
n inclu
ude
ed here forr de
eve
elo
opm
men
nt and
a d clar
c rificcattion
n of mar
m rk
scche
eme
e.
Prrog
gramm
min
ng lan
ngu
uag
ge solution
ns app
a pea
ar in the
t e App
A pen
ndix
x.

IN
NPU
UT St
tar
rtP
Pos
s
IN
NPU
UT Nu
umT
ToC
Cha
ang
ge

2

Pape
er
2
22

6

1

FO
OR n ← 0 to
o Num
N mTo
oCh
han
nge
e - 1
OUT
O TPU
UT " In
npu
ut ne
ew va
alu
ue fo
or po
osi
ition
n "
INP
I PUT
T New
N wCh
har
r 4
Loo
L oku
up[St
tar
rtP
Pos
s + n
n] ← Ne
ewC
Cha
ar 5
NDF
FOR
R
EN

3

OU
UPU
UT (N
Num
mTo
oCh
han
nge
e & " ent
e tri
ies c
cha
ang
ged
d") 6
AL
LTE
ER
RNA
ATIV
VE
E:
IN
NPU
UT St
tar
rtP
Pos
s
IN
NPU
UT Nu
umT
ToC
Cha
ang
ge
n ← 0

2

1

RE
EPE
EAT
T
OUT
O TPU
UT " In
npu
ut ne
ew va
alu
ue fo
or po
osi
ition
n "
INP
I PUT
T New
N wCh
har
r 4
Loo
L oku
up[St
tar
rtP
Pos
s + n
n] ← Ne
ewC
Cha
ar 5
n ← n + 1
UN
NTI
IL n = Nu
umT
ToC
Cha
ang
ge

3

OU
UTP
PUT
T (Nu
umT
ToC
Cha
ang
ge & " en
ntr
rie
es ch
han
nge
ed") 6

Mark
k poin
p nts ass ciirclled
d, des
d scriptions as
a below
w:

4

(a))

1.
2.
3.
4.
5.
6.

Tw
wo IN
NPU
UT sta
ateme
entts
Wo
ork
king
g lo
oop
p (u
usiing
g va
alues off n fro
om flo
owc
cha
art))
OU
UTP
PUT
Tp
prom
mp
pt (exa
actt te
ext no
ot spe
s eciffied
d)
IN
NPU
UT Ne
ewC
Cha
ar
As
ssig
gnm
me
ent of Ne
ewC
Cha
ar to co
orre
ect arrray
y elem
e me
ent
OU
UTP
PUT
T fina
al mes
m ssa
age
e affter lo
oop
p (e
exa
actt te
ext no
ot specifiied
d bu
ut mu
ust inc
clu
ude
e
Nu
umT
ToC
Cha
ange orr lo
oop
p co
oun
nte
er iff va
alue cor
c rrec
ct a
at tha
t at poin
p nt)

•
•

Pro
ogram
m ccod
de is eas
e sie
er to
o im
mp
plem
me
ent / ma
m nage
Mo
odu
ules m
may be
b giv
ven
n to
o diffe
erent peop
ple to de
evelop
p // giv
ven
n to
o pro
p gra
am
m
specialiistss
Pro
ogram
m ccod
de is eas
e sie
er to
o te
estt / de
d bug / main
ntain
En
nco
oura
age
es the
e re-u
usa
ability
y off prrog
gram code

•
•

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6

Max
M x2

www.dynamicpapers.com
Pag
P ge 7

Mar
M k Sch
S hem
me
e
C mb
Cam
brid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16

Ques
Qu
stio
on

Sylllab
S
bus
9 08
960

An
nsw
wer

(b) (i)

Pape
er
2
22
Mar
M rks
s
3

One mark
k per co
orre
ect an
nno
otattion
n as
a sho
s ow
wn
Arrrow
ws
s may
m y be
e draw
d wn
n clockw
wise
e or anti
a iclo
ock
kwise
Diiam
mon
nd sy
ymb
bol may
m y be
e filled
d or
o unf
u fille
ed but
b t mus
m st b
be in pos
p sitiion
n sh
how
wn
(ii)

A (orr B)
B – Card
C d deta
d ails
s / Ca
ard nu
um
mbe
er / Ca
ard
d in
nfo
B (orr A)
A – Cos
C st deta
ails
s / am
amou
untt pa
aya
able
e / prrod
duc
ct ccostt / tot
t al billl
C
– (F
Fla
ag) ind
dic
cato
or ffor su
ucc
ces
ssfu
ul pay
p yme
entt /// pa
aym
ment confirmation

3

Da
ata
a ite
em
ms for
f A an
nd B are
a e interrchange
eab
ble
5

(a)) (i)

•
•
•

So
o th
hat the
e dat
d a / infforrma
atio
on is sav
s ved
d afte
a er the prrog
gram
m is
i rrun
n / wh
when
n th
he
comp
putter is sw
witc
che
ed o
off
So
o th
he dat
d ta / in
nforrmation ca
an be accce
ess
sed
d ne
extt tim
me
e th
he pro
p ogram
m is
s ru
un
So
o th
he dat
d ta info
orm
mation can
c n be "pe
" erm
man
nen
ntly
y sttore
ed""

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6

Max
M x1

www.dynamicpapers.com
Page 8

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Question
(ii)

Syllabus
9608

Answer
Problem:
• When retrieving / searching for / editing (text relating to a particular CD)
• Can’t tell where the artist name stops and the title begins (or any similar
explanation or example)
Solution 1:
• Use of a separator character// or by example
• Where the separator character does not occur in the original strings
Solution 2:
• Use a fixed number of characters for each data item
• Data items are padded with e.g. <Space> character where needed
Solution 3:
• Convert original data items to CamelCase
• …and add a Space separator
Mark as follows:
Two marks for description of problem
Two marks for description of solution

© Cambridge International Examinations 2016

Paper
22
Marks
4

www.dynamicpapers.com
Page 9

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Question
(b)

Syllabus
9608

Paper
22

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

CDTitle : STRING
CDArtist : STRING
CDLocation : STRING
FileData : STRING

OPENFILE "MyMusic" FOR WRITE
OUTPUT "Input CD Title"
INPUT CDTitle
WHILE CDTitle <> "##"
OUPUT "Input CD Artist"
INPUT CDArtist
OUPUT "Input CD Location"
INPUT CDLocation
FileData = CDTitle & ':' & CDArtist & ':' &
CDLocation
WRITEFILE "MyMusic.txt", FileData
OUTPUT "Input CD Title"
INPUT CDTitle
ENDWHILE
CLOSEFILE("MyMusic.txt ")
ENDPROCEDURE
One mark for each of the following:
•
•
•
•
•
•
•
•
•

Procedure heading and ending
Declaration of CDTitle, CDArtist and CDLocation
Open file for writing (Allow MyMusic or MyMusic.txt)
Working conditional loop structure including test for rogue value (including initial
input of CDTitle)
Input of three data values (CDTitle, CDArtist and CDLocation) inside a
loop
String concatenation of three variables inside a loop
Write three variables in single line to file inside a loop
Close file
Use of string separator

Solutions may repeatedly OPEN – WRITE – CLOSE within the loop.In this case the first
OPEN could be in WRITE or APPEND mode with all others in APPEND.

© Cambridge International Examinations 2016

Marks
Max 8

www.dynamicpapers.com
Pag
ge 10
1

Mar
M k Sch
S hem
me
e
C mb
Cam
brid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16

Ques
Qu
stio
on
6

Sylllab
S
bus
9 08
960

Pape
P
er
2
22

An
nsw
wer

(a))

n

f

0
0

0

Marrks
s

x

y

MI
ID(S
Str
rin
ng1
1, x
x, 1)

M D(S
MID
Str
rin
ng2, y,
y 1)
)

1

1

'R
R'

'R
R'

2

2

'E
E'

'A
A'

2

2

1

'E
E'

'R
R'

3

3

1

'T
T'

'R
R'

4

4

1

'R
R'

'R
R'

5

2

'A
A'

'A
A'

6

3

'C
C'

'C
C'

1

6

4
One mark
k per co
orre
ect co
olum
mn
n

(b) (i)

•
•
•
•

o e mar
m rk iff anytthing els
se on
n firrst row
w
Minus one
Co
olum
mn
n 2 – '4' mu
ustt no
ot pre
p ece
ede
e '4
4' in
n co
olu
umn
n 1 (a
as sho
s ow
wn b
by arrrow
w)
Le
ette
ers mu
ustt all be in u
upp
perr ca
ase
e
Ign
norre quo
q ota
atio
on sym
s mb
bol

•
•

to searc
ch forr a strring
gw
with
hin an
nother strin
ng / Str
S rin
ng2
2 with
w hin St
tri
ing1
n th
he po
osittion
no
of th
he sta
art of St
tri
ing2 within St
S ri
ing
g1 // by
b exa
am
mple
e
to retturn

2

Firstt mark
k poin
p nt: allow
w lo
oca
ate / fiind
d / cal
c culate
e pos
p sitio
on of
(ii)

Va
alu
ue: 0 / ze
ero
o

2

Meanin
ng: St
tring2 no
ot fou
f und
d in
n Strin
ng1
1
(iii)

Optiion
n1
•
•

2

It is pos
p ssib
ble
e to
o “fa
all offf” th
he en
nd of
o Stri
ing
g1 (orr by
y exa
e amp
ple
e) whi
w le strring
g
ma
atch
h (ffor ex
xam
mplle, Sttring1 = "R
Retrrac
ce", Strin
ng2
2 = "R
Rac
ced
d")
MI
ID (S
Str
ring
g1, x,
x 1)// de
esc
crip
ptio
on of
o 'su
' bscript out of ra
ang
ge''

Optiion
n2
•
•

If eith
e herr sttring is em
e ptyy th
hen
n
subsc
crip
pt o
outt off ra
ang
ge errrorr // de
escripttion
n

Optiion
n3
•
•

If Str
S ing
g1 ffou
und
d with
w hin String
g2
An
n en
ndllesss loop will
w occcu
ur

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6

www.dynamicpapers.com
Page 11

Mark Scheme
Cambridge International AS/A Level – May/June 2016
Appendix - Program Code Solutions

3

(b) (ii): VB.NET

Console.Write("Enter start position: ")
StartPos = Console.ReadLine()
Console.Write("Enter number to change: ")
NumToChange = Console.ReadLine()
For n = 0 To NumToChange - 1
Console.Write("Enter new value for position: ")
NewChar = Console.ReadLine()
Lookup(StartPos + n) = NewChar
Next
Console.WriteLine(NumToChange & " entries changed")
ALTERNATIVE:
Console.Write("Enter start position: ")
StartPos = Console.ReadLine()
Console.Write("Enter number to change: ")
NumToChange = Console.ReadLine()
n = 0
Do
Console.Write("Enter new value for position: ")
NewChar = Console.ReadLine()
Lookup(StartPos + n) = NewChar
n = n + 1
Loop Until n = NumToChange
Console.WriteLine(NumToChange & " entries changed")

3

(b) (ii): Pascal

write('Enter start position: ');
readln(StartPos);
write('Enter number to change: ');
readln(NumToChange);
for n := 0 to NumToChange - 1 do
begin
write('Input new value for position: ');
readln(NewChar);
LookUp[Startpos + n] := NewChar;
end;
writeln(IntToStr(NumToChange) + ' entries changed');

© Cambridge International Examinations 2016

Syllabus
9608

Paper
22

www.dynamicpapers.com
Page 12

Mark Scheme
Cambridge International AS/A Level – May/June 2016

ALTERNATIVE:
write('Enter start position: ');
readln(StartPos);
write('Enter number to change: ');
readln(NumToChange);
n := 0;
repeat
write('Input new value for position: ');
readln(NewChar);
LookUp[Startpos + n] := NewChar;
n := n + 1;
until (n = NumToChange);
writeln(IntToStr(NumToChange) + ' entries changed');
3

(b) (ii): Python

StartPos = int(input("Enter start position: "))
NumToChange = int(input("Enter number to change: "))
for n in range(NumToChange) :
NewChar = input("Input new value for position: ")
LookUp[StartPos + n - 1] = NewChar
print(str(NumToChange) + " entries changed")
ALTERNATIVE:
StartPos = int(input("Enter start position: "))
NumToChange = int(input("Enter number to change: "))
n = 0
while n < NumToChange :
NewChar = input("Input new value for position: ")
LookUp[StartPos + n] = NewChar
n = n + 1
print(str(NumToChange) + " entries changed")

© Cambridge International Examinations 2016

Syllabus
9608

Paper
22

www.dynamicpapers.com
Page 13
5

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Syllabus
9608

Paper
22

(b): VB.NET

A StreamWriter() solution:
Sub InputData()
Dim CDTitle, CDArtist, CDLocation As String
Dim FileHandle As IO.StreamWriter
FileHandle = New IO.StreamWriter("MyMusic.txt") ("MyMusic.txt")
Console.WriteLine("Input CD Title: ")
CDTitle = Console.ReadLine()
Do Until CDTitle = "##"
Console.WriteLine("Input CD Artist: ")
CDArtist = Console.ReadLine()
Console.WriteLine("Input CD Location: ")
CDLocation = Console.ReadLine()
FileHandle.WriteLine(CDTitle & ":" & CDArtist & ":" & CDLocation)
Console.WriteLine("Input CD Title: ")
CDTitle = Console.ReadLine()
Loop
FileHandle.Close()
End Sub
A legacy FileOpen() solution:
Sub InputData()
Dim CDTitle, CDArtist, CDLocation As String
FileOpen(1, "MyMusic", OpenMode.Output)
Console.WriteLine("Input CD Title: ")
CDTitle = Console.ReadLine()
Do Until CDTitle = "##"
Console.WriteLine("Input CD Artist: ")
CDArtist = Console.ReadLine()
Console.WriteLine("Input CD Location: ")
CDLocation = Console.ReadLine()
Print(1, CDTitle & ":" & CDArtist & ":" & CDLocation)
Console.WriteLine("Input CD Title: ")
CDTitle = Console.ReadLine()
Loop
FileClose(1)
End Sub

© Cambridge International Examinations 2016

www.dynamicpapers.com
Page 14
5

Mark Scheme
Cambridge International AS/A Level – May/June 2016

Syllabus
9608

Paper
22

(b): Pascal

procedure InputData;
var
CDTitle, CDArtist, CDLocation : string;
CDFile : Textfile;
begin
assign(CDFile, 'MyMusic');
rewrite(CDFile);
writeln('Input CD Title: ');
readln(CDTitle);
while (CDTitle <> '##') do
begin
writeln('Input CD Artist: ');
readln(CDArtist);
writeln('Input CD Location: ');
readln(CDLocation);
writeln(CDFile, CDTitle + ':' + CDArtist + ':' + CDLocation);
writeln('Input CD Title: ');
readln(CDTitle);
end;
close(CDFile);
end;

5

(b): Python

def InputData() :
#CDTitle String (or CDTitle = "")
#CDArtist String (or CDArtist = "")
#CDLocation String (or CDLocation = "")
FileHandle = open("MyMusic", "w")
CDTitle = input("Input CD Title: ")
while CDTitle != "##" :
CDArtist = input("Input CD Artist: ")
CDLocation = input("Input CD location: ")
FileHandle.write(CDTitle + ":" + CDArtist + ":" + CDLocation)
CDTitle = input("Input CD Title: ")
FileHandle.close()

© Cambridge International Examinations 2016

Advertisement