Past-paper question · 2019 October-November · Paper 21 · Q6(b)

Question 6(b) 2019 · October-November · Paper 21 · 7 marks

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 7

✓
scheme.
✓
Programming language example solutions appear in the Appendix.
✓
FUNCTION SearchFileNtoZ(AccNum : STRING) RETURNS BOOLEAN
✓
DECLARE FileData : STRING
✓
DECLARE Found : BOOLEAN
✓
CONSTANT SearchFile = "UserListNtoZ.txt"
✓
Found ← FALSE
✓
OPENFILE SearchFile FOR READ
✓
WHILE NOT EOF(SearchFile) AND NOT Found
✓
READFILE SearchFile, FileData
✓
IF AccNum & ' * ' = LEFT(FileData, LENGTH(AccNum)+ 1)
✓
THEN
✓
Found ← TRUE
✓
ENDIF
✓
ENDWHILE
✓
CLOSEFILE SearchFile
✓
RETURN Found
✓
ENDFUNCTION
✓
One mark for each of the following:
✓
1.
✓
Function heading and ending, (ignore parameter) and returned BOOLEAN
✓
2.
✓
File OPEN UserListNtoZ.txt in READ mode and CLOSE
✓
3.
✓
Conditional loop repeating until EOF() or 'Found'
✓
4.
✓
Read a line from the file in a loop
✓
5.
✓
Compare the correct number of characters with AccNum in a loop
✓
6.
✓
Set termination logic if found in a loop
✓
7.
✓
Return Boolean value
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2019
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_21.pdf →

Show text version of question

Question 6

Part (b)

Question 6

Account information for users of a library is held in one of two text files; UserListAtoM.txt and

UserListNtoZ.txt

The format of the data held in the two files is identical. Each line of the file is stored as a string that contains an account number, name and telephone number separated by the asterisk character ('*') as follows:

<Account Number>'*'<Name>'*'<Telephone Number>

An example of one line from the file is:

"GB1234*Kevin Mapunga*07789123456"

The account number string may be six or nine characters in length and is unique for each person. It is made up of alphabetic and numeric characters only.

An error has occurred and the same account number has been given to different users in the two files. There is no duplication of account numbers within each individual file.

A
program is to be written to search the two files and to identify duplicate entries. The account

number of any duplicate found is to be written to an array, Duplicates, which is a 1D array of 100 elements of data type STRING.

The program is to be implemented as several modules. The outline description of three of these is as follows:

Module Outline description

ClearArray()

  • Initialise the global array Duplicates. Set all elements to the
  • empty string.

  • Read each line from the file UserListAtoM.txt
  • Check whether the account number appears in file
  • UserListNtoZ.txt using SearchFileNtoZ() FindDuplicates() • If the account number does appear then add the account number to the array.

  • Output an error message and exit the module if there are more
  • duplicates than can be written to the array.

  • Search for a given account number in file UserListNtoZ.txt
  • SearchFileNtoZ()

  • If found, return TRUE, otherwise return FALSE

Part (b)

Write program code for the module SearchFileNtoZ().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[7]

Question 14

Topic relevance

Why this question appears here

72% assigned-topic match · Hardware › Logic gates and logic circuits

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_21.pdf

Keep practising this topic