Past-paper question · 2015 May-June · Paper 22 · Q5(e)(ii)

Question 5(e)(ii) 2015 · May-June · Paper 22 · 7 marks

Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Original past-paper question for 5(E)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 5(E)(II)

Official answer for Question 5

Part (e)

(ii)

(ii)

Mark as follows:

✓
Open file statement
✓
(1)
✓
File read statement for line text – NextLine
✓
(1)
✓
File close statement
✓
(1)
✓
Input of the required date – ThisDate
✓
(1)
✓
Isolate NextDate from NextLine
✓
(1)
✓
Isolate NextDiscount from NextLine
✓
(1)
✓
IF statement comparing the two dates
✓
(1)
✓
Uses Boolean variable Found to flag when found
✓
(1)
✓
Post/pre condition loop iterate through the file
✓
(1)
✓
Test for EOF or ‘found’
✓
(1)
✓
Note: These must follow some correct logic to score …
✓
Output ‘No discount on this date’ and Output ’This is a discount date’)
✓
(1)
✓
Output (when date not found) ‘Date not found’
✓
(1)
✓
[max 7]
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – May/June 2015
✓
9608

Question 22

✓
APPENDIX
✓
Programming Solutions
✓
Question 1 (b) (ii)
✓
Visual Basic …
✓
Dim
✓
RaceHours As Integer
✓
Dim
✓
RaceMinutes As Integer
✓
Dim
✓
RaceSeconds As Integer
✓
Dim
✓
RaceTimeInSeconds As Integer
✓
Dim
✓
PersonalBest As Integer
✓
Console.Write("Time in hours ... ") : RaceHours = Console.ReadLine
✓
Console.Write("Time in minutes... ") : RaceMinutes = Console.ReadLine
✓
Console.Write("Time in seconds ... ")
✓
RaceSeconds = Console.ReadLine
✓
Console.Write("Personal best in seconds ... ")
✓
PersonalBest = Console.ReadLine
✓
RaceTimeInSeconds = RaceHours*60*60 + RaceMinutes*60 + RaceSeconds
✓
Console.Write(RaceTimeInSeconds)
✓
If RaceTimeInSeconds < PersonalBest Then
✓
Console.WriteLine("New personal best time")
✓
Else
✓
If RaceTimeInSeconds = PersonalBest Then
✓
Console.WriteLine("Equals personal best time")
✓
Else
✓
Console.WriteLine("Below personal best")
✓
End If
✓
End If
✓
Python …
✓
#
✓
RaceHours
✓
-
✓
Integer
✓
#
✓
RaceMinutes
✓
-
✓
Integer
✓
#
✓
RaceSeconds
✓
-
✓
Integer
✓
#
✓
RaceTimeInSeconds
✓
-
✓
Integer
✓
#
✓
PersonalBest
✓
-
✓
Integer
✓
RaceHours = int(input("Time in hours ... "))
✓
RaceMinutes = int(input("Time in minutes... "))
✓
RaceSeconds = int(input("Time in seconds ... "))
✓
PersonalBest = int(input("Personal best in seconds ... "))
✓
RaceTimeInSeconds = RaceHours*60*60 + RaceMinutes*60 + RaceSeconds
✓
if RaceTimeInSeconds < PersonalBest:
✓
print("New personal best time")
✓
elif RaceTimeInSeconds == PersonalBest:
✓
print("Equals personal best time")
✓
else:
✓
print("Below personal best")
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – May/June 2015
✓
9608

Question 22

✓
Programming Solutions
✓
Question 1 (b) (ii) – contd.
✓
Pascal …
✓
var
✓
RaceHours
✓
:
✓
Integer
✓
;
✓
var
✓
RaceMinutes
✓
:
✓
Integer
✓
;
✓
var
✓
RaceSeconds
✓
:
✓
Integer
✓
;
✓
var
✓
RaceTimeInSeconds
✓
:
✓
Integer
✓
;
✓
var
✓
PersonalBestTime
✓
:
✓
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
✓
Mark Scheme
✓
Syllabus
✓
Paper
✓
Cambridge International AS/A Level – May/June 2015
✓
9608

Question 22

✓
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.
✓
Read customer file")
✓
Console.WriteLine("2.
✓
Add customer")
✓
Console.WriteLine("3.
✓
Search for a customer")
✓
Console.WriteLine("4.
✓
End")
✓
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()

Mark scheme 9608_s15_ms_22.pdf →

Show text version of question

Question 5

Part (e)

(ii)

Question 5

A company creates two new websites, Site X and Site Y, for selling bicycles.

Various programs are to be written to process the sales data.

These programs will use data about daily sales made from Site X (using variable SalesX) and Site Y (using variable SalesY).

Data for the first 28 days is shown below.

SalesDate SalesX SalesY 1 03/06/2015 0 1 2 04/06/2015 1 2 3 05/06/2015 3 8 4 06/06/2015 0 0 5 07/06/2015 4 6 6 08/06/2015 4 4 7 09/06/2015 5 9 9 11/06/2015 4 1 …

The DISCOUNT_DATES text file is successfully created.

The company now wants a program to:

  • key in a date entered by the user
  • search the text file for this date
  • if found, output one of the following messages:
  • o “No discount on this date” o “This is a discount date”

  • if not found, output “Date not found”

(ii)

Write the program code.

Do not include any declaration or comment statements for the variables used.

Programming language .....................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[7]

Question 20

effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

82% assigned-topic match · Hardware › Logic gates and logic circuits

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s15_qp_22.pdf

Keep practising this topic