Question 6(c) 2019 · October-November · Paper 22 · 3 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (c)
Question 3
Show text version of question
Question 6
Part (c)
Question 6
A text file, StudentList.txt, contains a list of information about students in a school.
Each line of the file contains a reference, name and date of birth for one student. All the information is held as strings and separated by the asterisk character ('*') as follows:
<Reference>'*'<Name>'*'<Date Of Birth>
An example of one line from the file is:
"G1234*Aleza Hilton*05062001"
The reference string may be five or eight characters in length and is unique for each student. It is made up of alphabetic and numeric characters only.
school. The array consists of 500 elements of data type STRING. Unused elements contain the empty string "".
only for students who are still attending the school.
The program is to be implemented as several modules. The outline description of three of these is as follows:
Module Outline description
- Read each line from the file StudentList.txt
- Check whether the Reference appears in the
- If the Reference does not appear then write the
- Return the number of lines not copied.
- Search for a given Reference in the array Leavers
- Take two parameters: the name of an array and a
- Count the number of elements that are the same as
array using SearchLeavers() ProcessStudentList()
line to the file UpdatedList.txt
SearchLeavers() • If the Reference is found, return TRUE, otherwise return FALSE
string. CountTimes()
the string. Return the count value.
Question 15
Part (c)
CountTimes() is to be used to count how many unused elements there are in the Leavers
array. An unused element is one that contains an empty string.
The module description is repeated here for reference.
Module Outline description
- Take two parameters: the name of an array and a
- Count the number of elements that are the same as
string. CountTimes()
the string. Return the count value.
Write a statement in program code that uses CountTimes() to assign the count of unused elements to the variable Result.
Programming language ............................................................................................................
Program code
...................................................................................................................................................
.............................................................................................................................................
Question 18
Appendix Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString
Example: MID("ABCDEFGH", 2, 3) returns "BCD"
LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of 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 "ABC"
RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString
Example: RIGHT("ABCDEFGH", 3) returns "FGH"
INT(x : REAL) RETURNS INTEGER returns the integer part of x
Example: INT(27.5415) returns 27
NUM_TO_STRING(x : REAL) RETURNS STRING returns a string representation of a numeric value. Note: This function will also work if x is of type INTEGER
Example: NUM_TO_STRING(87.5) returns "87.5"
STRING_TO_NUM(x : STRING) RETURNS REAL returns a numeric representation of a string. Note: This function will also work if x is of type CHAR
Example: STRING_TO_NUM("23.45") returns 23.45
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 19
Question 20
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 Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of Cambridge Local Examinations Syndicate (UCLES), which itself is 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_w19_qp_22.pdf
