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

Question 2(a)(ii) 2018 · October-November · Paper 22 · 5 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)

✓
FUNCTION GetTotal() RETURNS REAL

Question 5

✓
DECLARE Valid : BOOLEAN
✓
DECLARE Amount : REAL
✓
Valid ← FALSE
✓
REPEAT
✓
OUTPUT "Enter the amount"
✓
INPUT Amount
✓
IF Amount > 0 AND Amount < 10000
✓
THEN
✓
Valid ← TRUE
✓
ENDIF
✓
UNTIL Valid = TRUE
✓
RETURN Amount
✓
ENDFUNCTION
✓
Note that the pseudocode shown is only an example. The use of an explicit
✓
flag and IF structure are not essential provided the functionality is provided.
✓
1 mark for each of:

Question 1

✓
declaration of local variable(s) used

Question 2

✓
prompt followed by input

Question 3

✓
conditional loop

Question 4

✓
checking that input value > 0 and input value < 10000

Question 5

✓
returning the value

Mark scheme 9608_w18_ms_22.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 each

time they buy items. The number of points they collect depends on:

  • the total amount they spend
  • the number of points already collected.

The function CalcPoints() takes the card number and the total amount spent as parameters. It returns the number of new points collected. 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 OldPoints INTEGER The number of points already collected NewPoints INTEGER The number of new points collected Total REAL The amount spent Takes the card number as a parameter and returns the GetPoints() FUNCTION number of points already collected INT() FUNCTION Refer to the Appendix on page 16

START

Is YES Total > 100 ?

OldPoints NO GetPoints(CardNum)

Is NO OldPoints > 2000 ?

YES

NewPoints INT(Total * 1.2)

NewPoints 0 NewPoints INT(Total * 1.1)

RETURN NewPoints

END

Question 5

(ii)

The value of the total amount spent is calculated by an Electronic Point Of Sale (EPOS)

system. This system does not have the prices of all items. For these items, a valid total amount has to be entered manually.

A
function, GetTotal(), prompts the user to input this value.

If the user enters a valid value greater than 0 and less than 10 000, the function returns the value. The function prompts the user to re-enter the value each time the user enters an invalid value.

Write pseudocode to complete the GetTotal() function.

FUNCTION GetTotal() RETURNS REAL

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

........................................................................................................................................... ENDFUNCTION

[5]

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

Keep practising this topic