Past-paper question · 2019 October-November · Paper 22 · Q6(a)

Question 6(a) 2019 · October-November · Paper 22 · 6 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 6

✓
scheme.
✓
Programming language example solutions appear in the Appendix.
✓
FUNCTION SearchLeavers(Reference : STRING) RETURNS BOOLEAN
✓
DECLARE Index : INTEGER
✓
DECLARE Found : BOOLEAN
✓
Found ← FALSE
✓
Index ← 0
✓
WHILE Index < 500 AND NOT Found
✓
IF Reference = Leavers[Index]
✓
THEN
✓
Found ← TRUE
✓
ENDIF
✓
Index ← Index + 1
✓
ENDWHILE
✓
RETURN Found
✓
ENDFUNCTION
✓
One mark for each of the following:
✓
1.
✓
Function heading (and ending) as above
✓
2.
✓
Initialisation and increment of Index used to index Leavers array in a
✓
loop
✓
3.
✓
Conditional loop repeating while Index < 500 and exit loop if
✓
Reference is found:
✓
4.
✓
Compare indexed array element value with Reference in a loop
✓
5.
✓
Set termination logic if found in a loop
✓
6.
✓
Return Boolean value
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2019
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_22.pdf →

Show text version of question

Question 6

Part (a)

Question 6

A text file, StudentList.txt, contains a list of information about students in a school.

Each line of the file contains a reference, name and date of birth for one student. All the information is held as strings and separated by the asterisk character ('*') as follows:

<Reference>'*'<Name>'*'<Date Of Birth>

An example of one line from the file is:

"G1234*Aleza Hilton*05062001"

The reference string may be five or eight characters in length and is unique for each student. It is made up of alphabetic and numeric characters only.

A
global 1D array, Leavers, contains the references of all students who have recently left the

school. The array consists of 500 elements of data type STRING. Unused elements contain the empty string "".

A
program is to be written to produce a new text file, UpdatedList.txt, containing information

only for students who are still attending the school.

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

Module Outline description

  • Read each line from the file StudentList.txt
  • Check whether the Reference appears in the
  • array using SearchLeavers() ProcessStudentList()

  • If the Reference does not appear then write the
  • line to the file UpdatedList.txt

  • Return the number of lines not copied.
  • Search for a given Reference in the array Leavers
  • SearchLeavers() • If the Reference is found, return TRUE, otherwise return FALSE

  • Take two parameters: the name of an array and a
  • string. CountTimes()

  • Count the number of elements that are the same as

the string. Return the count value.

Question 15

Part (a)

Write program code for the module SearchLeavers(). Declare any additional variables

you use.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[6]

Question 16

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

Keep practising this topic