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

Question 2(a) 2024 · October-November · Paper 22 · 6 marks

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

Official answer for Question 2

Part (a)

Question 6

✓
FUNCTION Conceal(CardNumber : STRING) RETURNS STRING
✓
DECLARE MaskedString : STRING
✓
DECLARE Count : INTEGER
✓
CONSTANT Asterisk = '*'
✓
MaskedString RIGHT(CardNumber, 4)
✓
FOR Count 1 TO LENGTH(CardNumber) - 4
✓
MaskedString Asterisk & MaskedString
✓
NEXT Count
✓
RETURN MaskedString
✓
ENDFUNCTION
✓
Mark as follows:
✓
MP1 Function heading and parameter and ending and return type
✓
MP2 Declaration of all local variables used - including the loop counter
✓
MP3 Calculate number of digits to mask / number of asterisks required
✓
use of a ‘relevant’ Loop
✓
MP4
✓
MP5
✓
Correct number of iterations
✓
MP6
✓
Concatenate asterisk to start/end of MaskedString in a loop
✓
MP7
✓
Assign last four characters to MaskedString // Concatenate the
✓
retained original last four digits
✓
MP8
✓
Return masked string
✓
ALTERNATIVE ‘non loop’ solution:
✓
FUNCTION Conceal(CardNumber : STRING) RETURNS STRING
✓
DECLARE MaskedString : STRING
✓
DECLARE Count : INTEGER
✓
CONSTANT Asterisks = " ******************** " //20
✓
asterisks
✓
Count LENGTH(CardNumber) - 4
✓
MaskedString LEFT(Asterisks, Count) &
✓
RIGHT(CardNumber, 4)
✓
RETURN MaskedString
✓
ENDFUNCTION
✓
Mark as follows:
✓
MP1 Function heading and parameter and ending and return type
✓
MP2 Declaration of all local variables used
✓
MP3 Calculate number of digits to mask / number of asterisks required
✓
Cambridge International AS & A Level – Mark Scheme
✓
9618/22
✓
October/November
✓
PUBLISHED
✓
2024
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_w24_ms_22.pdf →

Show text version of question

Question 2

Part (a)

Question 2

A program is being developed to process bank card information.

When a card number is displayed, all the characters except the last four are replaced with the asterisk character '*'.

Card numbers are stored as strings. The strings are between 10 and 20 characters in length.

The function Conceal() will take a string representing a card number and return a modified string.

Example strings:

Original string Modified string

Part (a)

The function Conceal() will:

  • take a numeric string as a parameter representing the card number
  • return a string in which the asterisk character replaces all except the last four characters

of the card number parameter.

Write pseudocode for the function Conceal().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[6]

Question 5

, ,

Topic relevance

Why this question appears here

71% assigned-topic match · Programming › Structured programming

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 9618_w24_qp_22.pdf

Keep practising this topic