Вы находитесь на странице: 1из 12

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.

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 12 printed pages.

© UCLES 2016 [Turn over


Page 2 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

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

© Cambridge International Examinations 2016


Page 3 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

2 (a) [5]

Identifier Data Type Description

Accelerator position
Values: 0 to 100 in steps of 1
Accelerator INTEGER
Meaning:
0 : none (not pressed)
100: maximum (fully pressed)

REAL / FLOAT / Engine temperature in °C


EngineTemp SINGLE / (–50 to +150 correct to 1 decimal
DOUBLE 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

Value used to signal engine must be


stopped
EngineStop BOOLEAN
Possible values:
TRUE: stop engine
FALSE: run engine

One mark per row


Data types as shown

© Cambridge International Examinations 2016


Pag
P ge 4 Mar
M k Sch
S hemme
e Sylllab
S bus Pape
P er
C mb
Cambrid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16 9 08
960 2
23

( )
(b) [6
6]
IN
NPUT
T Acc
A cel
lera
ato
or
IN
NPUT
T E gin
Eng neTe
emp
p
1
IN
NPUT
T N rma
Nor alTe
emp
p
IN
NPUT
T S eed
Spe d
3

IF Ac
cce
ele
era
ator
r = 0 A
AND
D En
ngi
ineeTe
emp
p >=
= N
Nor
rma
alTe
emp
p AND
A D Spee
ed = 0
TH
HEN
N
E gin
Eng neSt
top
p ← T
TRU
UE 4
2
EL
LSE
E
E gin
Eng neSt
top
p ← F LSE
FAL 5
EN
ND
DIF
F

OU
UTPU
UT "E
Eng
gine
e Sto
S opp
ped
d" 6

M rk points
Mar s as
a ccirc
cled, de
escripttion
ns as
s be
elo
ow:

1.
1 Four IN
NPPUT T stattemmenntss (c
corrrec
ct nam
n mes s and
a d se
equ uence e)
2
2. Corr
C rec ct IF.
I ..T THEN N..EL LSEE..END DIFF in
nclu
uding
g firrst conditio
on (orr eq
quiiva
alen
nt nes
n sted IFs
I s)
3
3. Corr
C rec ct sec
s con nd and
a d th
hirdd con
c ndittionns
4
4. Corr
C rec ct THE
T EN sta ate
emeentt
5
5. Corr
C rec ct ELS
E SE sta ate
emeentt
6
6. Outp
O putt inndiccatting
g Eng
E gine eStopp
(F
Follow
winng EENDIF or a tw
o as wo sep paratte sta
s temmeentss with
w hin TH N and
HEN a d EL LSE)

3 (
(a) [[11]
FUN
F TION
NCT N Dec
D cry
ypt Loo
t (L oku
up : ARR
A RAYY, Ci
iph
heerC
Cha
ar : CHA
AR) RET
R TURNS CH
RN HAR
R
D
DEC
CLA
ARRE Fo
oun
nd : BOO
B OLEAAN
D
DEC
CLA
ARRE In
nde
ex : INT
I TEGEER
D
DEC
CLA
ARRE Or
rig
ginnalC ar : CHA
Cha C ARR

I dex ← 1
Ind // tar
/st rt
t w
wit
th fi
irstt ele
e emeent
t in
n the
t e arr
a raay //
/
a si
as ign
n the
t e st
tarrt in
nde
exx
F und ← F
Fou FAL
LSEE
///no
ow seearch fo or Ciiphe
erCChaar inn Loooo
okuup:
W
WHI
ILEE Fo nd = FA
oun AL
LSEE //
/ Fo ouund < TR
d <> RUEE //
/ NOT
N T Fo
F unnd
// coomp
parre CippheerC
Chaar wit
w th th his
s arrra
ay ellem
mentt:
I Loo
IF up[In
L oku nddex
x] = Ci iph
herCChaar
TH
HEN
N
Fo nd ← TRU
oun T UE // Seet thhe flaag
ELSE
EL E
In ex ← Ind
nde I dex + 1 //M
Movve too nnext arr
a ray
y el
e emmen
nt
E DIF
EN
E DWHILE
END E
/ drop
//d ppe
ed ouut of lo oop
p so
s mus
m st ha ave
e fooun
nd Ciiph
herCChaar:
:
O
Ori
iginnal
lCh
harr ← CH HR
R(IInd
dexx) // conc nveertt In
ndeex to
o or
o iggin
nall ch
c arac
cte
er
R
RET
TUR N Ori
RN O igiina
alChharr

E DFU
END UNCTIO
ON

O e mar
One m rk for
f r ea
ach
h partt-sttate
em
men
nt (s
sho
owwn 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 hemme
e Sylllab
S bus Pape
P er
C mb
Cambrid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16 9 08
960 2
23

( ) 'P
(b) Pseu
udo
ocoode
e' s
sollution
n in
ncllud
ded
d her
h re fforr de
eve
elo
opm me
ent an
nd claarifficatiion
n of th
he mark
k
s hem
sch mee. Pro
P ogrram
mmmingg lannguuag
ge ex
xam
mple so s luttions ap
ppe
earr in
n th
he Ap ppenndixx. [6
6]

INP
PUT
T S
Sta
art
tInd
dex
x
1
INP
PUT
T Num
N mbe
erTo
oOu
utp
put
t

FOR
R Ind x ← St
I dex tart
tIn
nde
ex to St
tar
rtI
Ind
dex + Nu
umb
berToO
Out
tpu
ut - 1

Or
rig ar ← CHR
nalCha
gin Index)
C R(I 3

4
2 Ci
iph
her har ← L
rCh Loo up[Ind
oku dex
x]
5
T ("Inde
O PUT
OUP ex " & Ind
dex
x & ":
" Cha ara
act r " & Or
ter rig nalC
gin ar &
Cha
" has
s sub
s bst
titu
ute
e c
cha
ara er " & Ciphe
acte erC ar)
Cha
6
END
DFO
OR

M rk points
Mar s as
a ccirc
cled, de
escripttion
ns as
s be
elo
ow:

1.
1 Twwoo IN
NPUT T sttate
em
men nts
2
2. Wor
W rkin ng loo
op using g In
ndeex (allow
w alte
a erna ativ
ve so ns inc
oluttion clud
ding sep
s parrate
e lo
oop
p cou
c unte
er)
3
3. Ass
A ign nmeentt (u
using coorre
ect va
aluees of Inddexx or
o oth
o er va aria
able
e)
4
4. Ass
A ign nmeentt (u
using coorre
ect va
aluees of Inddexx or
o oth
o er va aria
able
e)
5
5. One
O e mar
m rk foor OUUTPU UT of a stri
s ng co ombin ning textt and va aria
able
es...
6
6. ...a sec
s con
nd ma ark
k if OU
UTTPUUT strring
g iss com
c mplete ely co orre
ect

4 (
(a) • Functio
ons s / Prroc
cedurees [2
2]
• A ity to pa
Abil asss paara
ame ete
ers be
etw
wee
en m
mo
odu
ules
s
• Use
U e off lo
ocal / glo
oba v iab
al var bles
s

© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
Pag
P ge 6 Mar
M k Sch
S hemme
e Sylllab
S bus Pape
er
C mb
Cambrid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16 9 08
960 2
23

( ) (i)
(b) ( [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
A B C D E F

Prod
P ducct ID
I    ()

Qua
Q antiity )
( 

Flag
g Valu
V ue – indicaatin
ng
 
operattion
n succ
ces
ss or faiil

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
muust be
e op
ppo
osite of Roow 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 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

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.

© Cambridge International Examinations 2016


Page 8 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 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 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

© Cambridge International Examinations 2016


Pag
P ge 9 Mar
M k Sch
S hemme
e Sylllab
S bus Pape
P er
C mb
Cambrid
dge Inte
ern
nattional AS/
A /A Le
eve
el – May
M y/Ju
une 201
2 16 9 08
960 2
23

6 (
(a) (
(i) [4
4]
n x Fla
F ag m N
New
wString
g

– TRU
T UE 7 “
“”

1 ‘B
B FA
ALSE
E “B”

2 ‘i’ “B
Bi”

3 ‘g
g’ “B
Big””

4 ‘▽
▽’ TRU
T UE “Biig▽“

5 ‘B
B’ FA
ALSE
E “Big
“ g▽BB”

6 ‘e
e’ “B
Big
g▽B
Be”

7 ‘n
n’ “B ▽Be
Big▽ 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 indiccate
e req
r uirred se
equ
uennce
e (i.e. “B
B” ccan
n’t be in ro
ow befforre TR
TRUE
E)
• Leette
er ccas
se mu ust be
e as sho
s own
n
• Ignore quota atio
on symbbol
• Allow o ▽ fo
w “ “ or or spa
s acee sym
s mbo
ol

(ii) (T
To retturn a sttrin
ng wh
where
e:) [2
2]

• Th
he firsst cha
c ara
acte
er o
of eac
e ch wo d is ca
ord apittaliise
ed / mad
m de upp
u perr ca
ase
e /// byy exp
e plan
nattion
n
• Th
he rem maaining ch
harrac
cterrs (of
( eaachh word
w d) are a e mad
m de lowwerr ca
ase
e

( ) (i)
(b) ( • Th
he fun
ncttion
n operattes
s no
orm
mallly // retu
r urnns an
a ‘em
mp
pty strring
g’ [1]

(ii) Examp
ples o
of suit
s tabble tesst stri
s inggs: [3
3]

• Sttrin
ngss with alll ca
apitals
• Sttrin
ngss with alll lo
oweer cas
c se
• Sttrin
ngss with firs
st lett
l ters
s of
o wor
w rdss allrea adyy cap
c pita alise e. in cor
ed (i.e c rrect forrma
at)
• Sttrin
ngss in “re
eveersse” format – i.e. firrst lettterrs lo
ow
wer ca ase
e, thhe res
st up
u per case e
• Sttrin
ng wwith only
o y one
o e word
w d
• Sttrin
ngss with multiiplee spa
s aces
• ngss with nu
Sttrin umbers / sy ymmbo
ols

One
O e mar or ea
m rk fo ach string exa
e ample
epplus
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
Page 10 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

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)

© Cambridge International Examinations 2016


Page 11 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

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


Page 12 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 23

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()

© Cambridge International Examinations 2016

Вам также может понравиться