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

Question 5(d) 2015 · May-June · Paper 22 · 4 marks

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

Official answer for Question 5

Part (d)

Part (d)

OPENFILE "DISCOUNT_DATES" FOR WRITE / WRITING

✓
(1)
✓
INPUT NextDate
✓
(1)
✓
WHILE NextDate <> "XXX"
✓
INPUT Discount
✓
NextLine = CONCAT(NextDate, " ", Discount)
✓
(1)
✓
WRITEFILE "DISCOUNT_DATES", NextLine
✓
ENDWHILE
✓
(1)
✓
OUTPUT "File now created"
✓
CLOSEFILE
[4]

Mark scheme 9608_s15_ms_22.pdf →

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
A
programming language has the built-in function CONCAT defined as follows:

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

[4]

Question 17

Question 5(e) continues on page 18.

Question 18

Topic relevance

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

Keep practising this topic