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

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

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

Official answer for Question 6

Part (a)

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

Question 8

✓
scheme.
✓
Programming language example solutions appear in the Appendix.
✓
FUNCTION GetInfo() RETURNS STRING
✓
DECLARE ID : STRING
✓
DECLARE PreferredName : STRING
✓
DECLARE Valid : BOOLEAN
✓
Valid ← FALSE
✓
WHILE Valid = FALSE
✓
OUTPUT "Please Enter a valid ID"
✓
INPUT ID
✓
IF LENGTH(ID) = 5 AND LEFT(ID, 1) >= 'A'__
✓
AND LEFT(ID, 1) <= 'Z'__
✓
AND ISNUM(RIGHT(ID, 4))
✓
THEN
✓
Valid ← TRUE
✓
ENDIF
✓
ENDWHILE
✓
OUTPUT "Please enter preferred name"
✓
INPUT PreferredName
✓
RETURN ID & '*' & PreferredName
✓
ENDFUNCTION
✓
One mark for each of the following:
✓
1.
✓
Function header and end (where appropriate)
✓
2.
✓
Local variables used are declared (commented in python)
✓
3.
✓
Prompt and input for ID (until valid) and preferred name
✓
4.
✓
Conditional loop repeating while ID is invalid
✓
5.
✓
test length in a loop
✓
6.
✓
test first character in a loop
✓
7.
✓
test last four characters in a loop
✓
8.
✓
Concatenate using correct separator character and return resulting string
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2019
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s19_ms_22.pdf →

Show text version of question

Question 6

Part (a)

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 (a)

Write program code for the module GetInfo().

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 14

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