Past-paper question · 2019 May-June · Paper 22 · Q6(b)

Question 6(b) 2019 · May-June · Paper 22 · 8 marks

Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Reveal official mark-scheme answer Official mark-scheme answer for 6(B)

Official answer for Question 6

Part (b)

✓
‘Pseudocode’ solution included here for development and clarification of mark

Question 8

✓
scheme.
✓
Programming language example solutions appear in the Appendix.
✓
PROCEDURE TopLevel()
✓
DECLARE Response : CHAR
✓
DECLARE InputData : STRING
✓
DECLARE Success : BOOLEAN
✓
Response ← 'Y'
✓
WHILE Response = 'Y'
✓
InputData ← GetInfo()
✓
IF LEFT(InputData,1) < 'N'
✓
THEN
✓
Success ← WriteInfo(InputData, "File1.txt")
✓
ELSE
✓
Success ← WriteInfo(InputData, "File2.txt")
✓
ENDIF
✓
IF NOT Success
✓
THEN
✓
Response ← 'N'
✓
ELSE
✓
OUTPUT "Enter details for another student? (Y/N)"
✓
INPUT Response
✓
ENDIF
✓
ENDWHILE
✓
ENDPROCEDURE
✓
One mark for each of the following:
✓
1.
✓
Procedure header and end
✓
2.
✓
Conditional loop terminated with user input
✓
3.
✓
call to GetInfo()in a loop
✓
4.
✓
check first character of returned UserID value in a loop
✓
5.
✓
call(s) to WriteInfo() in both cases «
✓
6.
✓
« with two STRING parameters in a loop
✓
7.
✓
exit procedure if WriteInfo() unsuccessful in a loop
✓
8.
✓
if WriteInfo() successful, prompt and check input to repeat / exit in a
✓
loop

Mark scheme 9608_s19_ms_22.pdf →

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
  • 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

  • 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
  • GetInfo() • Input a user ID and repeat until the user ID is valid

  • Input a preferred name. This will be an empty string if no preferred
  • name is input.

  • Concatenate the user ID and preferred name using a '*' character as
  • a separator and return this string WriteInfo() • Open the file

  • Append the concatenated string to the file
  • Close the file
  • Return a Boolean value:

○ TRUE if the file write was successful ○ FALSE if the file write failed, for example, if the disk was full

A
valid user ID:
  • 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

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[8]

Question 15

Topic relevance

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

Keep practising this topic