Documente Academic
Documente Profesional
Documente Cultură
w
ap
eP
e
tr
.X
om
.c
s
er
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 2015 series for most
Cambridge IGCSE, Cambridge International A and AS Level components and some
Cambridge O Level components.
Page 2
1
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
(a)
Identifier
Data Type
Description
RaceHours
INTEGER
RaceMinutes
INTEGER
RaceSeconds
INTEGER // REAL
RaceTime
INTEGER // REAL
[3]
(b) (i)
Identifier
Data Type
Description
PersonalBestTime
INTEGER/REAL
[1]
(c) (i)
[max 7]
[2]
[6]
[3]
[1]
Page 3
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
(b) (i) 3
Paper
21
[1]
(ii) Previous design repeated indefinitely // (new design) limits number of attempts
Penalise "Program terminates/closes
(c) IF
IF
IF
IF
Choice
Choice
Choice
Choice
=
=
=
=
1
2
3
4
THEN
THEN
THEN
THEN
[1]
(CALL) ReadFile
OUTPUT "Add Customer code"
OUTPUT "Search Customer code"
END
(1)
(1)
(1)
(1)
alternative answer:
mark as follows:
CASE OF Choice // Select CASE Choice
1: (CALL) ReadFile
2: OUTPUT "Add Customer code"
3: OUTPUT "Search Customer code"
4: END
ENDCASE
1 mark
1 mark (allow CASE = 1)
1 mark
1 mark
[max 3]
[max 8]
Page 4
3
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
[1]
[1]
(b)
Any 2 correct
Any 3 correct
Data items
E
CustomerName
CustomerEmail
Model
Age
PolicyCharge
PolicyNumber
[4]
Page 5
4
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
(2)
(1)
(1)
(1)
(a)
1D Array // List
[1]
INTEGER
[1]
(b) (i)
x
DayNumber
OUTPUT
2
1
5/6/2015
4
2
7/6/2015
6
3
9/6/2015
3
Note: x and output entries must be on or below the relevant DayNumber entry
Mark as above
[4]
Page 6
Mark Scheme
Cambridge International AS/A Level May/June 2015
(ii)
Syllabus
9608
(1)
(1)
(1)
(1)
(c) (i) 2
Paper
21
[max 3]
[1]
(ii)
Tick
Cross
X //
[3]
(d) OPENFILE "DISCOUNT_DATES" FOR WRITE / WRITING
INPUT NextDate
WHILE NextDate <> "XXX"
INPUT Discount
NextLine = CONCAT(NextDate, " ", Discount)
WRITEFILE "DISCOUNT_DATES", NextLine
ENDWHILE
OUTPUT "File now created"
CLOSEFILE
(1)
(1)
(1)
(1)
[4]
STRING/DATE
BOOLEAN
NextLine
NextDate
NextDiscount
ThisMonth
MyStreamReader
STRING
STRING/DATE
STRING
INTEGER
STREAMREADER
[3]
Page 7
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
[max 7]
Page 8
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
APPENDIX
Programming Solutions
Question 1 (b) (ii)
Visual Basic
Dim
Dim
Dim
Dim
Dim
RaceHours As Integer
RaceMinutes As Integer
RaceSeconds As Integer
RaceTimeInSeconds As Integer
PersonalBest As Integer
RaceHours
RaceMinutes
RaceSeconds
RaceTimeInSeconds
PersonalBest
Integer
Integer
Integer
Integer
Integer
Page 9
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
Programming Solutions
Question 1 (b) (ii) contd.
Pascal
var
var
var
var
var
RaceHours
RaceMinutes
RaceSeconds
RaceTimeInSeconds
PersonalBestTime
:
:
:
:
:
Integer
Integer
Integer
Integer
Integer
;
;
;
;
;
begin
Writeln('Time in hours ... ') ; readln(RaceHours) ;
Writeln('Time in minutes... ') ; readln(RaceMinutes) ;
Writeln('Time in seconds ... ') ;
readln(RaceSeconds) ;
Writeln('Personal best in seconds ... ') ;
Readln(PersonalBest) ;
RaceTimeInSeconds := RaceHours*60*60 + RaceMinutes*60 + RaceSeconds
Writeln(RaceTimeInSeconds) ;
If RaceTimeInSeconds < PersonalBestTime Then
WriteLn('New personal best time')
Else
If RaceTimeInSeconds = PersonalBest Then
WriteLn('Equals personal best time')
Else
WriteLn('Personal best time is unchanged) ;
Readln;
End
Page 10
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Programming Solutions
Question 2 (d)
Visual Basic
Dim Choice As Integer
Dim NoOfAttempts As Integer
CONST i = 3
Do
Call DisplayMenu()
NoOfAttempts = 0
Do
Console.Write("Enter choice (1..4)"
Choice = Console.ReadLine
NoOfAttempts = NoOfAttempts + 1
Loop Until (Choice >= 1 And Choice <= 4) Or NoOfAttempts = i
If Choice = 1 Then Call ReadFile()
If Choice = 2 Then Console.WriteLine("Add customer code")
If Choice = 3 Then Console.WriteLine("Search customer code")
Loop Until Choice = 4
Sub DisplayMenu()
Console.WriteLine()
Console.WriteLine("1.
Console.WriteLine("2.
Console.WriteLine("3.
Console.WriteLine("4.
Console.WriteLine()
End Sub
Sub ReadFile()
Console.WriteLine("Read file code")
End Sub
Python
def DisplayMenu():
print()
print("1. Read customer file")
print("2. Add customer")
print("3. Search for a customer")
print("4. End")
print()
def ReadFile():
print("Read file code)
if __name__ ==__main__ :
# Choice - Integer
# NoOfAttempts - Integer
Choice = 0
while Choice !=4:
DisplayMenu()
Cambridge International Examinations 2015
Paper
21
Page 11
Mark Scheme
Cambridge International AS/A Level May/June 2015
Syllabus
9608
Paper
21
Page 12
Mark Scheme
Cambridge International AS/A Level May/June 2015
Programming Solutions
Question 5 (ii)
Visual Basic
Dim ThisDate As String : Dim NextDate As String
Dim FileString As String
Dim Found As Boolean
FileOpen(1, "D:DISCOUNT_DATES.txt", OpenMode.Input)
or equivalent for a StreamReader solutions
Console.Write("Date to find (DD/MM/YYYY)..")
ThisDate = Console.ReadLine
Found = False
Do
FileString = LineInput(1)
NextDate = Left(FileString, 10)
If NextDate = ThisDate Then
Found = True
' length is 15 when shows TRUE
If Len(FileString) = 15 Then
Console.WriteLine("This is a discount date")
Else
Console.WriteLine("No discount on this date")
End If
End If
Loop Until Found = True Or EOF(1)
FileClose(1)
If Found = False Then
Console.WriteLine("Date not found")
End If
Python
MyFile = open("c:\DISCOUNT_DATES.txt", "r")
ThisDate = input("Next date ...(XXX to end)")
Found = 0
while Found == 0:
NextLine = MyFile.readline()
if not NextLine:
break
FileDate = NextLine[0:10]
DiscountIndicator = NextLine[11:]
if FileDate == ThisDate:
Found = 1
print (ThisDate, DiscountIndicator)
MyFile.close()
if Found == 0:
Cambridge International Examinations 2015
Syllabus
9608
Paper
21
Page 13
Mark Scheme
Cambridge International AS/A Level May/June 2015
ThisDate
NextDate
TheFile
FileString
Found
:
:
:
:
:
String ;
String ;
Text ;
String ;
Boolean ;
begin
assign(TheFile, 'k:\DISCOUNT_DATES.txt') ;
reset(TheFile) ;
writeln('Date to find (DD/MM/YYYY)..')
readln(ThisDate) ;
Found := False ;
repeat
readln(TheFile, FileString) ;
NextDate := copy(FileString,1, 10) ;
If NextDate = ThisDate then
begin
Found := True ;
{ length is 15 when shows TRUE }
if length(FileString) = 15 then
writeLn('This is a discount date')
else
writeLn('No discount on this date')
end ;
until Found = True or EOF(TheFile) ;
close(TheFile) ;
if Found = False then writeLn('Date not found') ;
Syllabus
9608
Paper
21