Question 5 2017 · October-November · Paper 22 · 9 marks
Reveal official mark-scheme answer
Official answer for Question 5
Show text version of question
Question 5
stored in a text file, EmailDetails.txt. The format of each line of the text file is as follows:
<MembershipNumber><EmailAddress>
- MembershipNumber is a four-character string of numerals
- EmailAddress is a variable-length string
When members leave the club their details need to be removed from the file.
1. Input the MembershipNumber of the club member to be removed 2. Create a new file, NewEmailDetails.txt 3. Copy all the lines from EmailDetails.txt to NewEmailDetails.txt, except the line with the matching MembershipNumber
Write pseudocode for the procedure, RemoveDetails.
For the built-in functions list, refer to the Appendix on page 15.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.....................................................................................................................................................
Question 14
Question 15
Appendix
Built-in functions (pseudocode)
In each function, if the function call is not properly formed, the function returns an error.
MODULUS(x : INTEGER, y : INTEGER) RETURNS INTEGER
returns the remainder when x is divided by y using integer arithmetic. Example: MODULUS(5, 2) will return 1
INT(x : REAL) RETURNS INTEGER
returns the integer part of x. Example: INT(27.5415) returns 27
LENGTH(ThisString : STRING) RETURNS INTEGER
returns the integer value representing the length of string ThisString. Example: LENGTH("Happy Days") returns 10
LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING
returns leftmost x characters from ThisString. Example: LEFT("ABCDEFGH", 3) returns string "ABC"
RIGHT(ThisString : STRING, x : INTEGER) RETURNS STRING
returns rightmost x characters from ThisString. Example: RIGHT("ABCDEFGH", 3) returns string "FGH"
TONUM(ThisString : STRING) RETURNS INTEGER
returns a numeric value equivalent to ThisString. Example: TONUM("1201") returns integer value 1201
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings. & Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values. AND Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values. OR Example: TRUE OR FALSE produces TRUE
Question 16
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Why this question appears here
99% 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_w17_qp_22.pdf
