Past-paper question · 2018 October-November · Paper 23 · Q2(a)(ii)

Question 2(a)(ii) 2018 · October-November · Paper 23 · 6 marks

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

Official answer for Question 2

Part (a)

(ii)

✓
The pseudocode shown here is only an example. The use of an explicit flag

Question 6

✓
and IF structure are not essential provided the functionality is provided.
✓
FUNCTION GetCardNumber() RETURNS STRING
✓
DECLARE Valid : BOOLEAN
✓
DECLARE CardNum : STRING
✓
Valid ← FALSE
✓
REPEAT
✓
OUTPUT "Enter card number"
✓
INPUT CardNum
✓
IF LENGTH(CardNum) = 16 AND IS_NUM(CardNum) = TRUE
✓
THEN
✓
Valid ← TRUE
✓
ENDIF
✓
UNTIL Valid
✓
RETURN CardNum
✓
ENDFUNCTION
✓
1 mark for each of the following:

Question 1

✓
Declaring local variable to store user input

Question 2

✓
Conditional Loop

Question 3

✓
Prompt and input of CardNum

Question 4

✓
Length check

Question 5

✓
Checking IS_NUM(CardNum) is TRUE

Question 6

✓
Return a value

Mark scheme 9608_w18_ms_23.pdf →

Show text version of question

Question 2

Part (a)

(ii)

Question 2

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

they buy items. At the end of each year, customers are given bonus (extra) points related to the total amount they have spent during the year, and the number of points they have on their card.

The function CalcBonus() takes the card number as a parameter. It returns the bonus points for the customer. A flowchart for the function is shown.

The function uses the following variables and functions.

Identifier Data type Description CardNum STRING A numeric string representing the unique card number Points INTEGER The number of points collected Spend REAL The total amount that customer has spent during the year Bonus INTEGER The number of bonus points Takes the card number as a parameter and returns the GetPoints() FUNCTION number of points already collected Takes the card number as a parameter and returns the GetSpend() FUNCTION total amount that customer has spent during the year

START

Points GetPoints(CardNum)

Spend GetSpend(CardNum)

Is YES Points > 2000 ?

NO

Is YES Spend > 1000 ?

NO

Bonus 10 Bonus 50 Bonus 100

RETURN Bonus

END

Question 5

(ii)

The function GetCardNumber() prompts the user to input a card number until the

number input is valid.

A
valid card number has 16 characters. Each character is a numeric character ('0' to

'9').

Write pseudocode to complete the GetCardNumber() function.

You should refer to the function IS_NUM() in the Appendix on page 16.

FUNCTION GetCardNumber() RETURNS STRING

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ENDFUNCTION

[6]

Question 7

Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

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_23.pdf

Keep practising this topic