Past-paper question · 2018 October-November · Paper 21 · Q2(b)(ii)

Question 2(b)(ii) 2018 · October-November · Paper 21 · 2 marks

Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 2(B)(II)

Official answer for Question 2

Part (b)

(ii)

✓
Name: Stub testing

Question 2

✓
Description: A function could be written for GetPoints() that simply returns a
✓
test value or outputs a message (i.e. doesn't do the CardNum lookup)
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2018
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w18_ms_21.pdf →

Show text version of question

Question 2

Part (b)

(ii)

Question 2

Shop customers have a discount card with a unique card number. Customers collect points after

they have bought items. The more points they have, the bigger the discount. If they shop on a Wednesday, their discount is increased by 20%.

The function GetDiscountRate() takes a card number as a parameter and returns the discount rate for a customer based on the number of points they have collected. A flowchart for the function is shown.

The function uses the following variables and functions.

Identifier Data type Description DRate REAL The discount rate CardNum STRING The unique customer card number Points INTEGER The number of points collected Takes the card number as a parameter and returns the GetPoints() FUNCTION number of points already collected Today() FUNCTION Returns the day number: 1 for Monday, 2 for Tuesday etc.

START

DRate 0

Points GetPoints(CardNum)

Is YES Points > 199 ? DRate 0.2

NO

Is YES Points > 99 ? DRate 0.1

NO

Is Today = YES DRate DRate * 1.2 Wednesday ?

NO

RETURN DRate

END

Question 5

A
programmer writes the function GetDiscountRate() in a high-level language.

(ii)

Function GetPoints() has not been written yet.

Name and describe a strategy that can be used to test GetDiscountRate() before the GetPoints() function has been written.

Name .................................................................................................................................

Description ........................................................................................................................

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

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

[2]
Topic relevance

Why this question appears here

71% 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_w18_qp_21.pdf

Keep practising this topic