Past-paper question · 2018 May-June · Paper 22 · Q5(c)

Question 5(c) 2018 · May-June · Paper 22 · 4 marks

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

Official answer for Question 5

Part (c)

✓
Example ‘Pseudocode’ solution included here for development and

Question 4

✓
clarification of mark scheme.
✓
Programming language example solutions appear in the Appendix.
✓
FUNCTION GetNumber() AS STRING
✓
DECLARE Valid : BOOLEAN
✓
DECLARE MemberNumber : INTEGER
✓
REPEAT
✓
Valid ← TRUE
✓
OUTPUT "Please input a valid member number"
✓
INPUT MemberNumber
✓
IF (MemberNumber > 9999) OR (MemberNumber < 1111)
✓
THEN
✓
Valid ← FALSE
✓
ENDIF
✓
UNTIL Valid = TRUE
✓
RETURN STR(MemberNumber)
✓
ENDFUNCTION
✓
1 mark for each of the following:

Question 1

✓
Function heading (as above) and ending

Question 2

✓
Conditional loop structure

Question 3

✓
Condition to check valid membership number

Question 4

✓
Returning string value
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s18_ms_22.pdf →

Show text version of question

Question 5

Part (c)

Question 5

A golf club holds information about its members. When a member completes a round of golf, their

score is stored along with their membership number and the date of the round.

A
program is to be written to store and process the score information. The information to be stored

is formed into a string as follows:

<MembershipNumber><Date><Score>

Part (c)

The program needs a function, GetNumber(), to return a valid membership number. A valid

membership number is a four-digit numeric string between “1111” and “9999”.

The structured English representing the algorithm for this function is as follows:

1. Prompt and input a membership number. 2. Validate the membership number. 3. Repeat from step 1 if the membership number is invalid. 4. Return the valid membership number as a string.

An example of the function call in pseudocode is:

MembershipNumber GetNumber()

Write program code for the GetNumber() function.

Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.

Programming language ............................................................................................................

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[4]

Question 12

Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

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

Keep practising this topic