Question 5(d) 2015 · May-June · Paper 22 · 4 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (d)
Part (d)
OPENFILE "DISCOUNT_DATES" FOR WRITE / WRITING
Show text version of question
Question 5
Part (d)
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 …
Part (d)
The company decides to offer a discount on selected dates. A program is written to indicate
the dates on which a discount is offered.
The program creates a text file, DISCOUNT_DATES (with data as shown), for a number of consecutive dates.
03/06/2015 TRUE 04/06/2015 FALSE 05/06/2015 FALSE 06/06/2015 FALSE 07/06/2015 FALSE 08/06/2015 FALSE 09/06/2015 FALSE 10/06/2015 TRUE 11/06/2015 FALSE
01/07/2015 FALSE
Each date and discount indicator is separated by a single <Space> character.
The discount indicators are:
- FALSE – indicates a date on which no discount is offered
- TRUE – indicates a date on which a discount is offered
CONCAT(String1 : STRING, String2 : STRING [, String3 : STRING] ) RETURNS STRING For example: CONCAT("San", "Francisco") returns "SanFrancisco" CONCAT("New", "York", "City") returns "NewYorkCity"
The use of the square brackets indicates that the parameter is optional.
Question 16
The following incomplete pseudocode creates the text file DISCOUNT_DATES.
Complete the pseudocode.
OPENFILE "DISCOUNT_DATES" FOR ..................................................................................
INPUT ......................................................................................................................................
WHILE NextDate <>"XXX"
INPUT Discount
…………..…………………… = CONCAT(NextDate, " ", Discount)
WRITEFILE "DISCOUNT_DATES", NextLine
INPUT NextDate
...................................................................................................................................................
OUTPUT "File now created"
CLOSEFILE
Question 17
Question 5(e) continues on page 18.
Question 18
Why this question appears here
82% assigned-topic match · Programming › Programming basics
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
