Beruflich Dokumente
Kultur Dokumente
COMPUTER SCIENCE
9608/23
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.
[Turn over
Page 2
1
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
Paper
23
(a) (i)
[6]
Item
Statement
Selection
Iteration
Assignment
MyName = "Gordon"
DegF = INT(DegF)
ENDIF
CASE OF MyFavourite
UNTIL x = 5
[6]
Item
Purpose of statement
[2]
Expression
Result
"Paint"
RIGHT(MID(MyString, 6, 10), 4)
"Main"
Page 3
2
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
(a)
Paper
23
[5]
Identifier
Data Type
Description
Accelerator position
Values: 0 to 100 in steps of 1
Accelerator
INTEGER
EngineTemp
REAL / FLOAT /
SINGLE /
DOUBLE
Engine temperature in C
(50 to +150 correct to 1 decimal
place)
NormalTemp
INTEGER
Speed
INTEGER
Meaning:
0 : none (not pressed)
100: maximum (fully pressed)
BOOLEAN
Possible values:
TRUE: stop engine
FALSE: run engine
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
Sylllab
S
bus
9 08
960
Pape
P
er
2
23
( )
(b)
[6
6]
IN
NPUT
T
IN
NPUT
T
IN
NPUT
T
IN
NPUT
T
Acc
A
cel
lera
ato
or
E gin
Eng
neTe
emp
p
N rma
Nor
alTe
emp
p
S eed
Spe
d
IF Ac
cce
ele
era
ator
r = 0 A
AND
D En
ngi
ine
eTe
emp
p >=
= N
Nor
rma
alTe
emp
p AND
A D Spee
ed = 0
TH
HEN
N
4
E gin
Eng
neSt
top
p T
TRU
UE
2
EL
LSE
E
E gin
Eng
neSt
top
p F
FAL
LSE
EN
ND
DIF
F
OU
UTPU
UT "E
Eng
gine
e Sto
S opp
ped
d"
M rk points
Mar
s as
a ccirc
cled, de
escripttion
ns as
s be
elo
ow:
1.
1
2
2.
3
3.
4
4.
5
5.
6
6.
Four IN
NP
PUT
T stattem
men
ntss (c
corrrec
ct nam
n mes
s and
a d se
equ
uence
e)
Corr
C rec
ct IF.
I ..T
THEN
N..EL
LSE
E..END
DIF
F in
nclu
uding
g firrst conditio
on (orr eq
quiiva
alen
nt nes
n sted IFs
I s)
Corr
C rec
ct sec
s con
nd and
a d th
hird
d con
c ndittion
ns
Corr
C rec
ct THE
T EN sta
ate
eme
entt
Corr
C rec
ct ELS
E SE sta
ate
eme
entt
Outp
O putt in
ndiccatting
g Eng
E gine
eStop
p
(F
Follow
win
ng E
ENDIF or
o as
a tw
wo sep
paratte sta
s tem
me
entss with
w hin TH
HEN
N and
a d EL
LSE)
[[11]
(
(a)
FUN
F
NCT
TION
N Dec
D cry
ypt
t (L
Loo
oku
up : ARR
A RAY
Y, Ci
iph
he
erC
Cha
ar : CHA
AR) RET
R TUR
RN
NS CH
HAR
R
D
DEC
CLA
AR
RE Fo
oun
nd
: BOO
B OLEA
AN
: INT
D
DEC
CLA
AR
RE In
nde
ex
I TEGE
ER
D
DEC
CLA
AR
RE Or
rig
gin
nalC
Cha
ar : CHA
C AR
R
I
Ind
dex 1
//
/st
tar
rt
t w
wit
th fi
irst
t ele
e eme
ent
t in
n the
t e arr
a ra
ay //
/
a si
as
ign
n the
t e st
tar
rt in
nde
ex
x
F
Fou
und F
FAL
LSE
E
//
/no
ow se
earch fo
or Ci
iphe
erC
Cha
ar in
n Lo
ooo
oku
up:
W
WHI
ILE
E Fo
oun
nd = FA
AL
LSE
E //
/ Fo
ou
und
d <>
< TR
RUE
E //
/ NOT
N T Fo
F un
nd
// co
omp
par
re Cip
phe
erC
Cha
ar wit
w th th
his
s ar
rra
ay el
lem
ment
t:
IF
I Loo
L oku
up[In
nd
dex
x] = Ci
iph
herC
Cha
ar
TH
HEN
N
Fo
oun
nd TRU
T UE
// Se
et th
he fla
ag
ELSE
EL
E
//M
In
nde
ex Ind
I dex + 1
Mov
ve to
o n
next arr
a ray
y el
e em
men
nt
EN
E DIF
E
END
DWHILE
E
/
//d
drop
ppe
ed ou
ut of lo
oop
p so
s mus
m st ha
ave
e fo
oun
nd Ci
iph
herC
Cha
ar:
:
O
Ori
igin
nal
lCh
har
r CH
HR
R(I
Ind
dex
x) // con
c nve
ert
t In
nde
ex to
o or
o ig
gin
nal
l ch
c arac
cte
er
R
RET
TUR
RN
N Ori
O igi
ina
alCh
har
r
E DFU
END
UNCTIO
ON
O e mar
One
m rk for
f r ea
ach
h partt-sttate
em
men
nt (s
sho
ow
wn und
u derrlin
ned
d an
nd bo
old))
Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
Pag
P ge 5
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
Sylllab
S
bus
9 08
960
Pape
P
er
2
23
( ) 'P
(b)
Pseu
udo
oco
ode
e' s
sollution
n in
ncllud
ded
d her
h re fforr de
eve
elo
opm
me
ent an
nd cla
arifficatiion
n of th
he mark
k
s hem
sch
me
e. Pro
P ogrram
mm
ming
g lan
ngu
uag
ge ex
xam
mple so
s luttions ap
ppe
earr in
n th
he Ap
ppen
ndix
x.
[6
6]
INP
PUT
T S
Sta
art
tInd
dex
x
PUT
T Num
N mbe
erTo
oOu
utp
put
t
INP
FOR
R Ind
I dex
x St
tart
tIn
nde
ex to St
tar
rtI
Ind
dex + Nu
umb
berToO
Out
tpu
ut - 1
Or
rig
gin
nalCha
ar CHR
C R(I
Index)
Ci
iph
her
rCh
har L
Loo
oku
up[Ind
dex
x]
3
4
5
O PUT
OUP
T ("Inde
ex " & Ind
dex
x & ":
" Cha
ara
act
ter
r " & Or
rig
gin
nalC
Cha
ar &
" has
s sub
s bst
titu
ute
e c
cha
ara
acte
er " & Ciphe
erC
Cha
ar)
6
END
DFO
OR
M rk points
Mar
s as
a ccirc
cled, de
escripttion
ns as
s be
elo
ow:
1.
1
2
2.
3
3.
4
4.
5
5.
6
6.
(
(a)
wo
o IN
NPUT
T sttate
em
men
nts
Tw
Wor
W rkin
ng loo
op using
g In
nde
ex (allow
w alte
a erna
ativ
ve so
oluttion
ns inc
clud
ding sep
s parrate
e lo
oop
p cou
c unte
er)
Ass
A ign
nme
entt (u
using co
orre
ect va
alue
es of Ind
dex
x or
o oth
o er va
aria
able
e)
Ass
A ign
nme
entt (u
using co
orre
ect va
alue
es of Ind
dex
x or
o oth
o er va
aria
able
e)
One
O e mar
m rk fo
or OU
UTPU
UT of a stri
s ng co
ombin
ning textt and va
aria
able
es...
...a sec
s con
nd ma
ark
k if OU
UT
TPU
UT strring
g iss com
c mplete
ely co
orre
ect
ons
s / Prroc
cedure
es
Functio
Abil
A ity to pa
ass
s pa
ara
ame
ete
ers be
etw
wee
en m
mo
odu
ules
s
Use
U e off lo
ocal / glo
oba
al var
v iab
bles
s
Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
[2
2]
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
Sylllab
S
bus
9 08
960
( ) (i)
(b)
(
Pape
er
2
23
[1]
One
O e mar
m rk fo
or corre
ect arrrow
w as
a sho
s own acce
eptt eithe
er dirrecttion
(ii)
[4
4]
P
Param
metter
Da
ata
a Ite
em
m
Prod
P duc
ct ID
I
Qua
Q antiity
Flag
g Valu
V ue indica
atin
ng
n succ
ces
ss or faiil
operattion
()
(
)
Mar
M rk as
a foll
f low
ws:
Row
R w 1: One
O e mar
m rk for
f ticck in A AND
A DB
B, one
o e ma
m rk forr D OR E
Row
R w 2: One
O e mar
m rk for
f D OR
R E (m
mu
ust be
e op
ppo
osite of Ro
ow 1)
Row
R w 3: One
O e mar
m rk for
f C AN
ND F
Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
Page 7
5
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
Paper
23
Effect:
All existing file lines / contents / data will be overwritten / deleted / lost
Solution:
[3]
Page 8
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
Paper
23
(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
DECLARE
DECLARE
DECLARE
DECLARE
DECLARE
CDTitle : STRING
CDArtist : STRING
CDSearch : STRING
FileData : STRING
Total : INTEGER
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:
Pag
P ge 9
6
(
(a)
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
Sylllab
S
bus
9 08
960
(
(i)
Pape
P
er
2
23
[4
4]
Fla
F ag
N
New
wString
g
TRU
T UE
B
B
FA
ALSE
E
B
Bi
g
g
B
Big
TRU
T UE
Biig
B
B
FA
ALSE
E
Big
gB
B
e
e
B
Big
gB
Be
n
n
B
Big
Be
en
One
O e mar
m rk p
perr co
orre
ectt co
olumn
n (c
collum
mn
ns 3 and
a d 4 co
oun
nt as 1))
Arrrow
wss indic
cate
e req
r uirred se
equ
uen
nce
e (i.e. B
B ccan
nt be in ro
ow befforre TR
TRUE
E)
Le
ette
er ccas
se mu
ust be
e as sho
s own
n
Ignore quota
atio
on symb
bol
Allow
w or
o fo
or spa
s ace
e sym
s mbo
ol
(ii) (T
To retturn a sttrin
ng wh
where
e:)
( ) (i)
(b)
(
Th
he firsst cha
c ara
acte
er o
of eac
e ch wo
ord
d is ca
apittaliise
ed / mad
m de upp
u perr ca
ase
e /// byy exp
e plan
nattion
n
Th
he rem
ma
aining ch
harrac
cterrs (of
( ea
ach
h word
w d) are
a e mad
m de low
werr ca
ase
e
Th
he fun
ncttion
n operattes
s no
orm
mallly // retu
r urn
ns an
a em
mp
pty strring
g
(ii) Examp
ples o
of suit
s tab
ble tesst stri
s ing
gs:
[2
2]
Sttrin
ngss with alll ca
apitals
Sttrin
ngss with alll lo
owe
er cas
c se
Sttrin
ngss with firs
st lett
l ters
s of
o wor
w rdss allrea
ady
y cap
c pita
alise
ed (i.e
e. in cor
c rrect forrma
at)
Sttrin
ngss in re
eve
ers
se format i.e. firrst lettterrs lo
ow
wer ca
ase
e, th
he res
st up
u per case
e
Sttrin
ng w
with only
o y one
o e word
w d
Sttrin
ngss with multiiple
e spa
s aces
Sttrin
ngss with nu
umbers / sy
ym
mbo
ols
One
O e mar
m rk fo
or ea
ach string exa
e ample
ep
plus
s sup
s ppo
ortin
ng ex
xpla
ana
atio
on.
Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
[1]
[3
3]
Page 10
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
Paper
23
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
Cambridge International AS/A Level May/June 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
Cambridge International Examinations 2016
Syllabus
9608
Paper
23
Page 12
Mark Scheme
Cambridge International AS/A Level May/June 2016
Syllabus
9608
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()
Paper
23