Question 6(b) 2019 · May-June · Paper 22 · 8 marks
Reveal official mark-scheme answer
Official answer for Question 6
Part (b)
Question 8
Show text version of question
Question 6
Part (b)
Question 6
Nadine is developing a program to store the ID and preferred name for each student in a school.
For example, student Pradeep uses the preferred name “Prad”.
The program will:
1. prompt and input a valid user ID and a preferred name 2. write the user ID and preferred name to one of two files 3. allow the user to end the program or repeat from step 1.
The program will consist of three separate modules. Each module will be implemented using either a procedure or a function.
Nadine has defined the modules as follows:
Module Description TopLevel() • Call GetInfo() to obtain a string containing a valid user ID and a preferred name
- Call WriteInfo() to write the string to either File1.txt or
- End the program if the file write was unsuccessful
- Input (Y/N) to either repeat for the next user ID or to end the program
- Input a preferred name. This will be an empty string if no preferred
- Concatenate the user ID and preferred name using a '*' character as
- Append the concatenated string to the file
- Close the file
- Return a Boolean value:
File2.txt depending on the first character of the user ID as follows: ○ ‘A’ to ‘M’: writes to File1.txt ○ ‘N’ to ‘Z’: writes to File2.txt For example, a string with a user ID of "G1234" writes to File1.txt
GetInfo() • Input a user ID and repeat until the user ID is valid
name is input.
a separator and return this string WriteInfo() • Open the file
○ TRUE if the file write was successful ○ FALSE if the file write failed, for example, if the disk was full
- is five characters in length
- has a single upper case alphabetic character followed by four numeric characters, for
example “G1234”.
Nadine has decided that global variables and nested modules must not be used.
Nadine wants all inputs to have suitable prompts.
Question 13
Part (b)
Write program code for the module TopLevel().
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 15
Why this question appears here
91% 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_22.pdf
