Question 6(a) 2019 · May-June · Paper 23 · 8 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (a)
Question 8
Show text version of question
Question 6
Part (a)
Question 6
A text file, StudentContact.txt, contains a list of names and telephone numbers of students
in a school. Not all students in the school have provided a contact telephone number. In this case, their name will not be in the file.
Each line of the file is stored as a string that contains a name and telephone number, separated by the asterisk character ('*') as follows:
<Name>'*'<TelNumber>, for example:
"Bill Smith*081234567"
of 40 elements of string data type. You can assume that student names are unique. Unused elements contain the empty string "".
names and numbers for all students in a particular class.
For each name contained in the ClassList array, the program will:
- search the StudentContact.txt file
- copy the matching string into ClassContact.txt if the name is found
- write the name together with “*No number” into ClassContact.txt if the name is not found.
The program will be implemented as three modules. The description of these is as follows:
Module Description ProcessArray() • Check each element of the array: ○ Read the student name from the array ○ Ignore unused elements ○ Call SearchFile() with the student name ○ If the student name is found, call AddToFile() to write the student details to the class file ○ If the student name is not found, call AddToFile() to write a new string to the class file, formed as follows: <Name>“*No number”
- Return the number of students who have not provided a
telephone number SearchFile() • Search for a given student name at the start of each line in the file StudentContact.txt: ○ If the search string is found, return the text line from StudentContact.txt ○ If the search string is not found, return an empty string AddToFile() • Append the given string to a specified file, for example, AddToFile(StringName, FileName)
Question 15
Part (a)
Write program code for the module SearchFile().
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 16
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_s19_qp_23.pdf
