cambridge international examinations cambridge international · pdf file© ucles 2016...
TRANSCRIPT
® IGCSE is the registered trademark of Cambridge International Examinations.
This document consists of 12 printed pages.
© UCLES 2016 [Turn over
Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE 9608/23
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.
Page 2 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
1 (a) (i) [6]
Item Statement Selection Iteration Assignment
1 WHILE DegF > 37.5 �
2 MyName = "Gordon" �
3 DegF = INT(DegF) �
4 ENDIF �
5 CASE OF MyFavourite �
6 UNTIL x = 5 �
One mark per row Additional ticks in any row cancels that row
(ii) [6]
Item Purpose of statement
1 (Start of) loop – repeat while DegF greater than 37.5
2 Assign (string) "Gordon" to MyName
3 Assign integer value / whole number part of DegF to DegF
4 End of an IF statement / selection statement
5 Head of CASE / selection statement based on variable MyFavourite
6 End of REPEAT / post-condition loop: repeated until x equals 5
Exact wording not important Explanation must refer to variables or values used in code (except for row 4)
(iii) [2]
Expression Result
'P' & MID(MyString, 13, 4) "Paint"
RIGHT(MID(MyString, 6, 10), 4) "Main"
Must have correct case Quotation marks optional
Page 3 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
2 (a) [5]
Identifier Data Type Description
Accelerator INTEGER
Accelerator position Values: 0 to 100 in steps of 1 Meaning: 0 : none (not pressed) 100: maximum (fully pressed)
EngineTemp REAL / FLOAT /
SINGLE / DOUBLE
Engine temperature in °C (–50 to +150 correct to 1 decimal place)
NormalTemp INTEGER Normal engine temperature in °C Whole number; typical value 90
Speed INTEGER Road speed of car (in km/hr) Values: 0 to 200 in steps of 1
EngineStop BOOLEAN
Value used to signal engine must be stopped Possible values: TRUE: stop engine FALSE: run engine
One mark per row Data types as shown
P
3
Pag
(
(
2
ge
(b)
(a)
4
)
M 12
34
5
6
F
E
O
IN
IN
IN
IN
I
EN
OU
Mar
1. 2.
3. 4.
5.
6.
FUN
D
D
D
I
F
W
E
/
O R
END
One
NP
NP
NP
NP
F
ND
UT
rk
FC
CC
C
O(F
NCT
DEC
DEC
DEC
Ind
Fou
WHI
I
E
END
//d
OriRET
DFU
e m
C
UT
UT
UT
UT
Ac
TH
EL
DIF
PU
po
ouCorr
CorrCorr
Corr
OutpFol
TI
CLA
CLA
CLA
de
un
//
ILE
/
IF
E
EN
DW
dr
igTUR
UN
mar
Cam
T A
T E
T N
T S
cce
HEN
E
LSE
E
F
UT
ints
r INrec
recrec
rec
putlow
ON
AR
AR
AR
x
d
/no
E
/
LTH
EL
DI
HI
op
inRN
CT
rk f
mb
Acc
Eng
Nor
Spe
ele
N
Eng
E
Eng
"E
s a
NPct I
ct sct T
ct E
t inwin
N D
RE
RE
RE
←
← ow
Foco
LooHEN
FoLSE
In
F
LE
ppe
nalN O
IO
for
brid
cel
gin
rma
eed
era
gin
gin
Eng
as c
PUTIF.
secTHE
ELS
ndicng E
Dec
Fo
InOr
1
F
se
ounomp
okuN
ounE
nde
E
ed
lChOri
ON
r ea
dg
le
ne
al
d
at
ne
ne
gi
circ
T s..T
conEN
SE
catEN
cry
oun
nderig
FAL
ea
nd par
up
nd
ex
ou
harigi
ach
e I
ra
Te
Te
or
St
St
ne
cle
tatTH
nd asta
sta
tingDI
ypt
nd
ex gin
LSE
rc
= re
[In
←
←
ut
r ←ina
h p
nte
©
ato
emp
emp
r =
top
top
e S
d,
temEN
andate
ate
g EF o
t
na
E
h
FAC
nd
← T
← I
o
← al
art
ern
Ca
or
p
p
= 0
p ←
p ←
Sto
de
menN..
d theme
eme
Engor a
(L
lC
fo
ALip
dex
TRU
Ind
f
CHCh
t-st
nat
amb
0 A
← T
← F
opp
esc
ntsEL
hirdent
ent
gineas
Loo
Cha
or
LSEphe
x]
UE
de
lo
HRhar
tate
M
tio
brid
AND
TRU
FAL
ped
ript
s (cLSE
d ct
t
eStw
oku
ar
Ci
E /erC
=
x
oop
R(Ir
em
Mar
na
dge
D
UE
LS
d"
tion
corrE.
con
topwo
up :
:
:
ip
//
Cha
Ci
+
p s
Ind
men
1
k S
l A
e In
En
E
ns
rec.E
ndit
p sep
: B I
C
//
a
he
Foar
iph
1
so
dex
nt (s
1
Sch
AS/
nter
ngi
as
ct nND
tion
pa
ABOOINT
CHA
/stas
erC
ouw
he
m
x)
sho
4
hem
/A
rnat
ine
s be
namDIF
ns
rat
ARROLTE
AR
tarsi
Cha
undwit
rC
/
/
mus
ow
4
5
6
me
Le
tion
eTe
elo
mesF in
te s
RAYEAGE
R
rtign
ar
d <th
Cha
/
/M
st
//
wn u
e
eve
nal
emp
ow:
s anclu
sta
Y, ANER
t wn t
in
<> th
ar
Se
Mov
ha
c
und
el –
Ex
p
andudi
tem
Ci
witthe
n
TRhis
et
ve
ave
con
der
– M
xam
>=
d seng
me
iph
th e
Lo
RUEs
th
to
e
nve
rlin
May
mina
= N
equg fir
ents
he
fist
ooo
Ear
he
o n
fo
ert
ned
y/Ju
atio
Nor
uerst
s w
erC
irtar
oku
//
rra
f
ne
oun
t
d an
3
un
ons
rma
nceco
with
Cha
strt
up
/ Nay
la
xt
nd
In
nd
3
e 2
s 20
al
e)nd
hin
ar
t ein
:
NOTel
ag
a
Ci
nde
bo
201
016
Te
itio
TH
:
elende
T Flem
arr
iph
ex
old)
16
6
emp
on
HEN
C
emeex
Fome
ray
he
to
)
p A
(or
N a
HA
entx
unnt
y e
rC
o o
AND
r eq
and
AR)
t
nd t:
el
Cha
or
S
D
qui
d EL
R
in
em
ar:
ig
Syl
9
Sp
iva
LS
RET
n t
men
:
gin
llab
960
ee
alen
E)
TUR
the
nt
nal
bu
08
ed
nt n
RN
e a
l c
s
=
nes
NS
arr
ch
P
0
ste
CH
ra
ar
Pa
2
d I
HAR
ay
ac
pe
23
IFs
[R
//
cte
er
[6
s)
[11
/
er
6]
]
P
4
Pag
(
(
2
ge
(b)
(a)
5
) 'Ps
M 123456
•
•
•
Pssch
Mar
1. 2. 3. 4. 5. 6.
•
•
•
euhem
I
I
F
E
rk
TwWAAO..
F
A
U
C
udome
NP
NP
OR
O
ND
po
woWorAssAssOne
.a s
un
Abil
Use
Cam
ocoe. P
PUT
PUT
R I
Or
Ci
OUP
DFO
ints
o INrkinignign
e msec
ctio
ity
e of
mb
odePro
T S
T N
Ind
rig
iph
PUT
OR
s a
NPng nmenme
marcon
ons
to
f lo
brid
e' sogr
Sta
Num
dex
gin
her
T
as c
UTlooentent
rk fond
s /
pa
oca
dg
solram
art
mbe
x ←
na
rCh
("
"
circ
T stop t (ut (uor ma
Pr
ass
l /
e I
lutmm
tI
er
←
lC
ha
In
h
cle
tateus
usiusiOUark
roc
s pa
glo
nte
©
ionming
nd
To
St
ha
r
de
as
d,
emingng ng UTk if
ced
ara
oba
ern
Ca
n ing l
dex
oOu
ta
ar
←
ex
s s
de
meng In
coco
PUOU
ure
ame
al v
nat
amb
nclan
x
utp
rt
←
L
"
sub
esc
ntsndeorreorreUT UT
es
ete
var
M
tio
brid
ludngu
put
tIn
← C
Loo
&
bst
ript
ex ectectof
TPU
ers
iab
Mar
na
dge
deduag
t
nde
CHR
oku
I
ti
tion
(al va vaa s
UT
be
bles
k S
l A
e In
d hge
ex
R(I
up
nd
tu
ns
lowaluealuestristr
etw
s
Sch
AS/
nter
herex
t
In
[I
dex
ute
as
w aes es ngring
wee
hem
/A
rnat
re fxam
o
de
nd
x &
e c
s be
alteof of cog is
en m
1
me
Le
tion
formp
St
x)
dex
& "
cha
elo
ernaIndInd
oms c
mo
e
eve
nal
r dele s
tar
x]
":
ara
ow:
ativdexdexbin
com
odu
el –
Ex
eveso
rtI
C
ac
ve x ox oninmpl
ules
3
4
– M
xam
elolut
Ind
ha
te
soor oor og tete
s
May
mina
opmtio
de
ara
er
olutothothextely
y/Ju
atio
mens
x
act
"
tioner er t aco
un
ons
ent ap
+
ter
&
ns vavand
orre
e 2
s 20
anppe
Nu
r
C
incariaaria
vaect
201
016
nd ear
umb
"
ip
cludableablearia
16
6
clar in
be
&
he
dine)e)able
arifn th
rT
Or
erC
g s
es
fiche
oO
rig
Cha
sep
...
S
atiAp
Out
gin
ar
par
Syl
9
ionpp
tpu
na
)
rate
llab
960
n oen
ut
lC
e lo
6
bu
08
f thndix
-
Cha
oop
s
he x.
1
ar
p c
P
m
&
cou
Pa
2
ark
unte
5
pe
23
k
er)
er
[6
[2
6]
2]
P
Pag
(
ge
(b)
6
) (
(i
(i)
i)
O
P
Q
Fo
MRRR
C
One
Prod
Qua
lagpe
MarRowRowRow
Cam
e m
duc
anti
g Vrat
rk aw 1w 2w 3
mb
mar
ct I
ity
Valution
as f: O: O: O
brid
rk fo
Da
ID
ue n s
follOneOneOne
dg
or
ata
– iucc
lowe me me m
e I
co
a Ite
ndces
ws:marmarmar
nte
©
rre
em
icass
rk frk frk f
ern
Ca
ect
m
atinor
for for for
nat
amb
arr
ng fai
ticD C
M
tio
brid
row
il
ck iORAN
Mar
na
dge
w a
n AR END
k S
l A
e In
as s
A AE (m F
Sch
AS/
nter
sho
ANDmu
hem
/A
rnat
ow
A
�
D Bust
me
Le
tion
n –
B, obe
e
eve
nal
– a
onee op
el –
Ex
cce
B
�
e mppo
– M
xam
ept
B
�
maosi
May
mina
t e
P
rk te
y/Ju
atio
ithe
Par
C
�
forof
un
ons
er
am
C
�
r D Ro
e 2
s 20
dir
met
Oow
201
016
rect
ter
D
�
(�
R E1)
16
6
tio
D
�
�)
E
n
E
(�
�
S
)
Syl
9
llab
960
F
�
bu
08
s PPa
2
pe
23
er
[1
[4
]
4]
Page 7 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
5 (a) (i) Explanation: [Max 3]
• Easier to separate the two strings // to retrieve / search for / edit (text relating to a CD)
• Obvious where CDTitle ends and CDArtist begins
Drawback:
• Takes up more / unnecessary space in the file
• If the string is bigger than 40 characters then data will be lost // string length is limited
• The additional spaces will need to be removed before strings can be used One mark per bullet
(ii) Problem: File mode = WRITE / file is opened for writing // by explanation [3]
Effect: All existing file lines / contents / data will be overwritten / deleted / lost Solution: WRITE should be changed to APPEND (allow meaningful example)
Allow first two mark points to be interchanged – read as one paragraph.
Page 8 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
(b) 'Pseudocode' solution included here for development and clarification of mark scheme. Programming language example solutions appear in the Appendix. [Max 10] PROCEDURE OutputLocationList()
DECLARE CDTitle : STRING
DECLARE CDArtist : STRING
DECLARE CDSearch : STRING
DECLARE FileData : STRING
DECLARE Total : INTEGER
DECLARE FileData : STRING
Total ← 0
OPENFILE "MyMusic" FOR READ
OUTPUT "Input Location"
INPUT CDSearch
WHILE NOT EOF("MyMusic")
READFILE ("MyMusic", FileData
IF RIGHT(FileData, 8) = CDSearch
THEN
CDTitle ← LEFT(FileData, 40)
CDArtist ← MID(FileData(41, 40)
OUPUT (CDTitle & " – " & CDArtist)
Total ← Total + 1
ENDIF
ENDWHILE
OUTPUT (Total & " CDs found"
CLOSEFILE("MyMusic")
ENDPROCEDURE
One mark for each of the following:
• Procedure heading and ending
• Declaration AND initialisation of variable used as counter (Total above)
• Prompt and input of location to search for CDSearch (or other name)
• Open file for reading (Allow MyMusic or MyMusic.txt)
• Working conditional loop structure including test for EOF
The following points must be present inside a loop
• Read a line from the file (or read complete file in one e.g. as list)
• Isolate 8 chars representing location and compare with CDLocation
• Extract strings representing CDTitle and CDArtist
• Output CDTitle and CDArtist (separator optional) if correct location found
• Increment Total if correct location found
The following points must be present after a loop
• Output message including number of CDs found at location (Total)
• Close file
P
6
Pag
(
(
ge
(a)
(b)
9
(
(i
) (
(i
(i)
i)
(i)
i)
O
•
•
•
•
(T
•
•
•
E
•
•
•
•
•
•
•
O
C
One
To
xa
One
Cam
n
–
1
2
3
4
5
6
7
e m
Ar
Le
Ig
Al
ret
Th
Th
Th
mp
St
St
St
St
St
St
St
e m
mb
mar
rrow
ette
no
low
tur
he
he
he
ple
trin
trin
trin
trin
trin
trin
trin
mar
brid
rk p
ws
er c
re
w “
n a
firs
rem
fun
s o
ngs
ngs
ngs
ngs
ng w
ngs
ngs
rk fo
dg
per
s in
cas
qu
“ o
a st
st c
ma
nct
of s
s w
s w
s w
s in
wit
s w
s w
or
e I
x
‘B
‘
‘g
‘▽
‘B
‘e
‘n
r co
dic
se
ota
or ▽
trin
cha
aini
tion
suit
ith
ith
ith
“re
h o
ith
ith
ea
nte
©
x
B
i’
g’
▽’
B’
e’
n’
orre
cate
mu
atio
▽ fo
ng w
ara
ng
n o
tab
all
all
firs
eve
only
m
nu
ach
ern
Ca
ect
e r
ust
on
or s
wh
acte
ch
pe
ble
l ca
l lo
st l
ers
y o
ulti
um
st
nat
amb
t co
req
be
sy
spa
here
er o
har
rat
tes
api
owe
lett
se”
one
iple
be
rin
M
tio
brid
F
T
FA
T
FA
olu
uir
e a
mb
ace
e:)
of e
rac
tes
st s
tal
er c
ters
fo
e w
e s
rs
g e
Mar
na
dge
Fla
TRU
AL
TRU
AL
mn
red
s s
bol
e s
eac
cter
s no
stri
s
cas
s o
rm
word
spa
/ sy
exa
k S
l A
e In
ag
UE
SE
UE
SE
n (c
se
sho
sym
ch
rs (
orm
ing
se
of w
at
d
ace
ym
am
Sch
AS/
nter
E
E
col
equ
own
mbo
wo
(of
mal
gs:
wor
– i
s
mbo
ple
hem
/A
rnat
lum
uen
n
ol
ord
ea
lly
rds
.e.
ols
e p
me
Le
tion
mn
nce
d is
ach
// r
s al
fir
plus
e
eve
nal
m
7
ns 3
e (i
ca
h w
retu
lrea
rst
s s
el –
Ex
m
7
3 a
.e.
apit
word
urn
ady
lett
sup
– M
xam
and
“B
tali
d) a
ns a
y c
ter
ppo
May
mina
N
d 4
B” c
ise
are
an
cap
rs lo
ortin
y/Ju
atio
New
“
“B
“B
co
can
ed /
e m
‘em
pita
ow
ng
un
ons
wS
“
“
“B
“B
“Bi
“Big
Big
Big▽
oun
n’t
/ m
mad
mp
alise
wer
ex
e 2
s 20
tr
“”
B”
Bi”
Big”
ig▽
g▽B
g▽B
▽Be
nt
be
mad
de
pty
ed
ca
xpla
201
016
ing
”
“
B”
Be”
en”
as
in
de u
low
str
(i.e
ase
ana
16
6
g
”
1)
ro
upp
wer
ring
e.
e, th
atio
)
ow
per
r ca
g’
in c
he
on.
bef
r ca
ase
cor
res
S
for
ase
e
rre
st u
Syl
9
re T
e //
ct
up
llab
960
TR
/ by
for
pe
bu
08
RUE
y e
rma
r c
s
E)
exp
at)
ase
P
plan
e
Pa
2
nat
pe
23
tion
er
[4
[2
n
[1
[3
4]
2]
]
3]
Page 10 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
Appendix – Program Code Example Solutions Q3 (b): VB.NET Console.WriteLine("Enter start position")
StartIndex = Console.ReadLine()
Console.WriteLine("Enter how many")
NumberToOutput = Console.ReadLine()
For Index = StartIndex To StartIndex + NumberToOutput - 1
OriginalChar = Chr(Index)
CipherChar = Lookup(Index)
Console.WriteLine("Index " & Index & ": Character " & OriginalChar &
" has substitute character " & CipherChar)
Next Index
Q3 (b): Pascal
Writeln('Enter start position');
Readln(StartIndex);
Writeln('Enter how many');
Readln(NumberToOutput);
For index := StartIndex To StartIndex + NumberToOutput – 1 Do
Begin
OriginalChar := chr(index);
CipherChar := Lookup[index];
writeln("Index " + index + ": Character " + OriginalChar +
" has substitute character " & CipherChar);
end;
Q3 (b): Python startIndex = int(input("enter start position"))
numberToOutput = int(input("enter how many"))
for index in range(startIndex, (startIndex + numberToOutput)) :
OriginalChar = chr(index)
CipherChar = Lookup[index]
print("Index " + (index) + ": Character " + OriginalChar +
" has subst char " + CipherChar)
Page 11 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
Q5 (b): VB.NET A StreamReader() solution: Sub OutPutLocationList()
Dim Total As Integer
Dim FileData As String
Dim ObjReader As IO.StreamReader
ObjReader = New IO.StreamReader("C:\MyMusic.txt")
Dim CDLocation As String
Dim CDTitle As String
Dim CDArtist As String
Total = 0
Console.WriteLine("Input location to search ")
CDSearch = Console.ReadLine
Do While ObjReader.Peek <> -1
FileData = ObjReader.ReadLine()
If Right(FileData, 8) = CDLocation Then
CDTitle = Left(FileData, 40)
CDArtist = Mid(FileData, 41, 40)
Console.WriteLine(CDTitle & " " & CDArtist)
Total = Total + 1
End If
Loop
Console.WriteLine(Total & " CDs were found")
ObjReader.Close()
End Sub
A legacy FileOpen() solution: Sub OutPutLocationList()
Dim Total As Integer
Dim FileData As String
FileOpen (1, "C:\MyMusic.txt", OpenMode.Input)
Dim CDLocation As String
Dim CDTitle As String
Dim CDArtist As String
Total = 0
Console.WriteLine("Input location to search ")
CDSearch = Console.ReadLine
Do While NOT EOF(1)
Input(1, FileData)
If Right(FileData, 8) = CDSearch Then
CDTitle = Left(FileData, 40)
CDArtist = Mid(FileData, 41, 40)
Console.WriteLine(CDTitle & " " & CDArtist)
Total = Total + 1
End If
Loop
Console.WriteLine(Total & " CDs were found")
FileClose(1)
End Sub
Page 12 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23
© Cambridge International Examinations 2016
Q5 (b): Pascal procedure OutputLocationList;
var
FileData, CDLocation, CDTitle, CDArtist : String;
CDFile : Textfile;
Total : Integer;
Begin
Total := 0;
Writeln('Input location to search ');
Readln(CDSearch);
AssignFile(CDFIle, 'MyMusic.txt');
Reset(CDFile);
While not eof(CDFile) Do
Begin
readln(CDFile, FileData);
If copy(FileData, 80, 8) = CDSearch Then
Begin
CDTitle := copy(FileData, 1, 40);
CDArtist := copy(FileData, 41, 40);
Writeln(CDTitle + ‘ : ‘ + CDArtist);
Total := Total + 1;
End;
End;
Writeln(Total + ‘ CDs were found’)
CloseFile(CDFile);
End
Q5 (b): Python #total : Integer
#CDSearch, LineOfText, LineString : String
Def OutPutLocationList():
FileHandle = open("MyMusicPy.TXT", "r")
total = 0
CDSearch = input("Enter location to search")
LineOfText = FileHandle.readline()
while len(LineOfText) > 0:
LineString = LineOfText[80:87] #extact last 8 characters
(location)
if LineString == CDSearch:
total = total+1
CDTitle = LineOfText[0:39] #extract CD title
CDArtist = LineOfText[40:79] #extract CD artist
print(CDTitle + ": " + CDArtist)
LineOfText = FileHandle.readline() #read next line
print("There are " + str(total) + " in that location")
FileHandle.close()