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 | |------------------------|------------------------| | "1234567890" | "******7890" | | "1234567897652" | "*********7652" | | "1234567890123456" | "************3456" |
- (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]
- (b)(i)The requirements have been changed. Conceal() will now be written as a procedure which will process 100 card numbers each time it is called. The card numbers will be stored in a 2D array CardNumber. The original string will be stored in column one and the modified string in column two. Write pseudocode to declare the array.[2]
- (b)(ii)The new procedure Conceal() will write the modified string to the corresponding element in column two. The array CardNumber is passed as a parameter to the new procedure Conceal(). Identify how this parameter should be specified in the new procedure header.[1]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [1] FUNCTION Conceal (CardNumber : STRING) RETURNS STRING
- [1] DECLARE MaskedString : STRING
- [1] DECLARE Count : INTEGER
- [1] CONSTANT Asterisk = '*'
- [1] MaskedString ← RIGHT(CardNumber, 4)
- [1] FOR Count ← 1 TO LENGTH(CardNumber) - 4
- [1] MaskedString ← Asterisk & MaskedString
- [1] NEXT Count
- [1] RETURN MaskedString
- [1] ENDFUNCTION
- [1] DECLARE CardNumber : ARRAY [1:100, 1:2] OF STRING
- [1] Correct dimensions
- [1] All other parts of the statement correct
- [1] Any reference to BYREF // 'by reference'
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →