14
ALevelCSOnline.CF ® IGCSE is the registered trademark of Cambridge International Examinations. This document consists of 14 printed pages. © UCLES 2016 [Turn over Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level COMPUTER SCIENCE 9608/21 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.

9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

  • Upload
    others

  • View
    11

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

® IGCSE is the registered trademark of Cambridge International Examinations.

This document consists of 14 printed pages.

© UCLES 2016 [Turn over

Cambridge International Examinations Cambridge International Advanced Subsidiary and Advanced Level

COMPUTER SCIENCE 9608/21

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: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 2 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

Question Answer Marks

1 (a) (i)

Item Statement Selection Iteration Assignment

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

6

(ii)

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

6

(iii)

Expression Result

"D" & RIGHT(MyString, 4) "Dance"

LEFT(RIGHT(MyString, 7), 3) "ten"

Must have correct case Quotation marks optional

2

Page 3: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 3 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

Question Answer Marks

2 (a)

Identifier Data Type 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

4

Page 4: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Q

Qu

P

ues

(b

Pag

stio

)

ge

on

4

M 1.

2.

3.

4.

5.

6.

7.

4

ark

4

C

k p

Se

preInp

Co

IF

claCo

Co

Se

giv

Cam

poin

ettin

eseput

orre

F..

ausorre

orre

ettin

ven

mb

A

I

I

T

I

E

nts

ng

entttin

ect

.TH

sesect

ect

ng

n

brid

Ala

NP

NP

em

F

ND

as

Al

t) g S

t va

HEN

s) t TH

t EL

Al

dg

rm

UT

UT

mpe

Te

TH

EL

IF

s ci

lar

Sen

alue

N.

HEN

LSE

lar

e I

mSt

T

S

ra

mp

HEN

LSE

ircl

rmS

ns

e a

.E

N

E s

rmS

nte

©

at

hr

en

tu

er

N

E

led

St

or

ass

LS

sta

stat

St

ern

Ca

e

es

so

re

at

Al

OU

OU

Al

d, d

at

rVa

sign

SE.

ate

tem

at

nat

amb

ho

rV

ur

lar

UTP

UTP

lar

des

e t

al

ned

..E

me

me

e t

M

tio

brid

FA

ld

Val

← S

e

rmS

PUT

PUT

rmS

scri

to F

an

d to

END

ent

nt

to F

Mar

na

dge

ALS

Va

ue

Sen

>

Sta

T "

T "

Sta

pti

FA

nd

o T

DI

ts a

as

FA

k S

l A

e In

SE

lu

nso

Th

ate

"Te

"Te

ate

on

LS

Th

Tem

F s

as s

sh

LS

Sch

AS/

nter

e

orV

re

e ←

emp

emp

e ←

s a

E (

hre

mpe

stru

sho

how

E w

hem

/A

rnat

Val

sh

← T

per

per

as

(Co

esh

er

uct

ow

wn

wit

1

me

Le

tion

An

lue

ol

TRU

rat

rat

FA

be

ond

hol

at

ture

wn

thin

2

e

eve

nal

nsw

e *

dV

UE

tur

tur

ALS

low

d. c

ld

ur

e w

n E

2

el –

Ex

we

* 1

al

re

re

SE

w:

che

Va

re (

with

LS

– M

xam

r

1.1

ue

Al

OK

eck

al

(m

h co

SE c

7

May

mina

135

lar

K"

k n

ust

orr

cla

7

y/Ju

atio

5

rm"

ot

t b

rec

aus

un

ons

"

es

e *

ct c

se o

3

6

e 2

s 20

se

* n

on

on

201

016

ntia

ot

dit

ly

16

6

al b

x)

ion

if m

5

but

n (o

ma

t m

or t

ark

S

mus

two

po

Syl

9

st b

o se

oin

llab

960

be c

ep

nt 1

bu

08

cor

ara

1 n

s

rre

ate

ot

P

ct

e IF

Pa

2

if

F

pe

21

er

M

M

Mar

Max

rks

x 6

s

Page 5: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 5 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

Question Answer Marks

3 (a) FUNCTION EncryptString (LookUp : ARRAY, PlainText : STRING) RETURNS STRING

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)

10

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

2

Page 6: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Q

4

Qu

P

ues

(a)

Pag

stio

(

)

ge

on

ii)

6

'PscPr

AL

M 1.

2.3.

4.

5.

6.

Psecherog

LTE

ark

2

2

C

udemegra

ER

k p

Tw

WoOU

IN

As

OU

Nu

Pro

Mosp

Pro

En

Cam

oce. mm

RNA

poin

wo

orkUTP

NPU

ssig

UTP

umT

og

oduec

og

nco

mb

od

min

ATIV

nts

IN

kingPUT

UT

gnm

PUT

ToC

ram

uleiali

ram

oura

brid

e' s

ng

IN

IN

FO

EN

OU

VE

IN

IN

n

RE

UN

OU

as

NPU

g loT p

Ne

me

T fi

Cha

m c

s mists

m c

age

dg

sol

lan

NPU

NPU

OR

O

I

L

NDF

UPU

E:

NPU

NPU

EPE

O

I

L

n

NTI

UTP

s ci

UT

oopprom

ewC

ent

na

an

cod

mas

cod

es

e I

luti

ngu

UT

UT

n

OUT

INP

Loo

FOR

UT

UT

UT

0

EAT

OUT

INP

Loo

n ←

IL

PUT

ircl

sta

p (ump

Cha

of

al m

ge

de

y b

de

the

nte

©

ion

uag

St

Nu

TPU

PUT

oku

R

(N

St

Nu

T

TPU

PUT

oku

← n

n

T (

led

ate

usipt (

ar

Ne

mes

or

is e

be

is e

e r

ern

Ca

n in

ge

tar

umT

0

UT

T N

up[

Num

tar

umT

UT

T N

up[

n +

=

Nu

d, d

me

ingexa

ewC

ssa

r lo

eas

giv

eas

e-u

nat

amb

clu

so

rtP

ToC

to

"

New

St

mTo

rtP

ToC

"

New

St

+ 1

Nu

umT

des

ent

g vaact

Cha

age

oop

sie

ven

sie

usa

M

tio

brid

ude

lut

Pos

Cha

o N

In

wCh

tar

oCh

Pos

Cha

In

wCh

tar

1

umT

ToC

scri

ts

alut te

ar

e af

p co

er to

n to

er to

abi

Mar

na

dge

ed

ion

s

ang

Num

npu

har

rtP

han

s

ang

npu

har

rtP

ToC

Cha

pti

esext

to

fte

oun

o im

o d

o te

lity

k S

l A

e In

he

ns a

ge

mTo

ut

r

Pos

nge

ge

ut

r

Pos

Cha

ang

on

ofno

co

r lo

nte

mp

iffe

est

y of

Sch

AS/

nter

re

app

oCh

ne

s +

e &

ne

s +

ang

ge

s a

f n ot s

orre

oop

er if

plem

ere

t / d

f pr

4

4

hem

/A

rnat

for

pea

han

ew

+ n

& "

ew

+ n

ge

&

as

frospe

ect

p (e

f va

me

nt

de

rog

me

Le

tion

An

r de

ar

nge

va

n]

e

va

n]

"

be

om ecif

ar

exa

alu

ent

pe

bu

gra

1

1

e

eve

nal

nsw

eve

in t

e -

alu

ent

alu

en

low

flofied

rray

act

e c

/ m

op

g /

m

1

el –

Ex

we

elo

the

- 1

ue

Ne

tri

ue

Ne

ntr

w:

owcd)

y e

t te

cor

ma

ple

m

co

– M

xam

r

opm

e A

fo

ewC

ies

fo

ewC

rie

cha

elem

ext

rrec

na

to

ain

de

May

mina

men

App

or

Cha

c

or

Cha

es

art)

me

no

ct a

ge

de

nta

y/Ju

atio

nt a

pen

po

ar

cha

po

ar

ch

)

ent

ot s

at t

eve

in

un

ons

and

ndix

osi

ang

osi

han

pe

tha

lop

5

5

e 2

s 20

d c

x.

iti

ged

iti

nge

cifi

at p

p //

5

201

016

clar

on

d")

on

ed"

ied

poin

giv

16

6

rific

n "

n "

)

d bu

nt)

ven

6

cat

ut

n to

6

tion

mu

o p

3

3

S

n o

ust

pro

Syl

9

f m

inc

gra

llab

960

mar

clu

am

bu

08

rk

ude

m

s

e

PPa

2

pe

21

er

M

M

Mar

6

Max

rks

x 2

s

Page 7: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Q

5

Qu

P

ues

(b

(a)

Pag

stio

)

(

)

ge

on

(i)

ii)

(i)

7

OArDi

A B C Da

ne rrowiam

(or(or

ata

C

mws

mon

r Br A

a ite

Soco

So

So

Cam

arks mnd

B) –A) –

em

o thmp

o th

o th

mb

k pmay

sy

– C– C– (F

ms f

hat put

he d

he d

brid

er y beymb

CardCosFla

for

theter

dat

dat

dg

coe dbol

d dst dag)

A

e dis

ta /

ta

e I

orredraw m

detaetaind

an

datsw

/ in

info

nte

©

ect wn

may

ailsailsdic

nd B

a / witc

nfor

orm

ern

Ca

ann cly be

s / s / acato

B a

infche

rm

ma

nat

amb

nnooce fi

Caamor f

are

fored o

ati

tio

M

tio

brid

otatkwlled

ardmoufor

e in

rmaoff

on

n c

Mar

na

dge

tionwise

d o

nuuntsu

ter

atio

ca

can

k S

l A

e In

n ae oor u

umt paucc

rch

on

an

n b

Sch

AS/

nter

as sr aunf

mbeayaces

an

is s

be

e "

hem

/A

rnat

shoantifille

er / ablessfu

ge

sav

ac

"pe

me

Le

tion

An

owicloed b

Cae / ul p

eab

ved

cce

erm

e

eve

nal

nsw

wnockbut

ardpr

pay

ble

d a

ess

man

el –

Ex

we

kwit m

d inrodyme

afte

sed

nen

– M

xam

r

se mus

nfo ducent

er t

d ne

ntly

May

mina

st b

ct ct //

he

ext

y st

y/Ju

atio

be

cost/ pa

pr

t tim

tore

un

ons

in p

t / taym

rog

me

ed"

e 2

s 20

pos

totme

gram

e th

"

201

016

siti

al nt

m i

he p

16

6

ion

billco

is r

pro

n sh

l nfi

run

ogr

how

rm

n / w

am

S

wn

ati

wh

m is

Syl

9

on

hen

s ru

llab

960

n th

un

bu

08

he

s PPa

2

pe

21

er

M

M

Mar

3

3

Max

rks

x 1

s

Page 8: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 8 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

Question Answer Marks

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

4

Page 9: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 9 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

Question Answer Marks

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

DECLARE CDTitle : STRING

DECLARE CDArtist : STRING

DECLARE CDLocation : STRING

DECLARE 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.

Max 8

Page 10: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Q

6

Qu

P

ues

(a)

(b

ag

stio

)

)

(

(i

ge 1

on

(i)

ii)

ii)

10

O

Fi

Va M

O

O

• O

n

0

1

2

3

4

ne

rst

alu

ea

pti

pti

pti

C

n

0

1

2

3

4

m

Mi

Co

Le

Ign

to

to

t m

ue:

nin

ion

It i

ma

MI

ion

If e

su

ion

If S

An

Cam

ark

nu

olum

ette

nor

se

ret

ark

0 /

ng:

n 1

s p

atch

ID

n 2

eith

bsc

n 3

Str

n en

mb

4

k p

s o

mn

ers

re q

arc

turn

k p

/ ze

St

pos

h (f

(S

her

crip

ing

ndl

brid

f

0

er

one

n 2

mu

quo

ch

n th

poin

ero

tr

ssib

for

Str

r st

pt o

g1 f

les

dg

co

e m

ust

ota

for

he

nt:

o

in

ble

ex

ri

trin

out

fou

ss l

e I

orre

mar

'4'

t al

atio

r a

po

all

g2

e to

xam

ng

g i

t of

und

oo

nte

©

x

1

2

2

3

4

5

6

ect

rk if

mu

l b

on s

str

osit

ow

no

o “fa

mpl

g1,

s e

f ra

d w

p w

ern

Ca

co

f a

ust

e i

sym

ring

tion

w lo

ot f

all

le,

x

em

ang

with

will

nat

amb

olum

nyt

t no

n u

mb

g w

n o

oca

fou

off

St

x,

pty

ge

hin

oc

M

tio

brid

y

1

2

1

1

1

2

3

mn

thi

ot p

upp

bol

with

of th

ate

und

f” th

trin

1

y th

err

St

ccu

Mar

na

dge

n

ng

pre

per

hin

he

/ fi

d in

he

g1

)//

hen

ror

ring

ur

k S

l A

e In

MI

'R

'E

'E

'T

'R

'A

'C

els

ece

r ca

an

sta

ind

n S

en

=

de

n

r //

g 2

Sch

AS/

nter

ID

R'

E'

E'

T'

R'

A'

C'

se

ede

ase

not

art

d / c

tr

nd o

"R

esc

de

2

hem

/A

rnat

(S

on

e '4

e

he

of

cal

in

of

Retr

crip

esc

me

Le

tion

An

Str

n fir

4' in

r s

St

cu

ng1

St

rac

ptio

ript

e

eve

nal

nsw

rin

rst

n co

trin

tri

late

1

ri

ce"

on o

tion

el –

Ex

we

ng1

row

olu

ng

in

e p

ing

, S

of '

n

– M

xam

r

1,

w

umn

/ S

g2

pos

g1

trin

'su

May

mina

x

n 1

Str

w

sitio

(or

ng2

bs

y/Ju

atio

x,

1 (a

rin

ith

on

r by

2 =

cri

un

ons

1)

as s

ng2

in S

of

y e

= "R

pt

e 2

s 20

sho

2 w

St

exa

Rac

ou

201

016

M

'R

'A

'R

'R

'R

'A

'C

ow

with

ri

amp

ced

t o

16

6

MID

R'

A'

R'

R'

R'

A'

C'

wn b

hin

ing

ple

d")

f ra

D(S

by

St

g1

e) w

ang

Str

arr

tri

// b

whi

ge'

S

rin

row

in

by

le

'

Syl

9

ng

w)

g1

exa

str

llab

960

2,

am

ring

bu

08

y

mple

g

s

y,

e

P

1)

Pa

2

)

pe

21

er

MMar

6

2

2

2

rkss

Page 11: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 11 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 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');

Page 12: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 12 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 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")

Page 13: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 13 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

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

Page 14: 9608 s16 ms 21COMPUTER SCIENCE 9608/21 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,

ALev

elCSO

nline

.CF

Page 14 Mark Scheme Syllabus Paper

Cambridge International AS/A Level – May/June 2016 9608 21

© Cambridge International Examinations 2016

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