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

Question 6(b) 2019 · October-November · Paper 22 · 9 marks

Original past-paper question for 6(B)
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)

✓
FUNCTION ProcessStudentList() RETURNS INTEGER

Question 9

✓
DECLARE NotCopied : INTEGER
✓
DECLARE FileData : STRING
✓
DECLARE Reference : STRING
✓
NotCopied ← 0
✓
OPENFILE "StudentList.txt" FOR READ
✓
OPENFILE "UpdatedList.txt" FOR WRITE
✓
WHILE NOT EOF("StudentList.txt")
✓
READFILE "StudentList.txt", FileData
✓
IF MID(FileData, 6, 1) = ' * '
✓
THEN
✓
Reference ← MID(FileData, 1, 5) // five char
✓
reference
✓
ELSE
✓
Reference ← MID(FileData, 1, 8) // eight char
✓
reference
✓
ENDIF
✓
IF SearchLeavers(Reference) = FALSE
✓
THEN
✓
WriteFile "UpdatedList.txt", FileData
✓
ELSE
✓
NotCopied ← NotCopied + 1
✓
ENDIF
✓
ENDWHILE
✓
CLOSEFILE "StudentList.txt"
✓
CLOSEFILE "UpdatedList.txt"
✓
RETURN NotCopied
✓
ENDFUNCTION
✓
One mark for each of the following:
✓
1.
✓
Function heading and ending as above
✓
2.
✓
Declaration and use of three local variables and initialisation of count to 0
✓
3.
✓
OPEN both files in correct mode and CLOSE
✓
4.
✓
Pre-Condition loop to go through the file StudentList.txt until EOF()
✓
5.
✓
Read line from StudentList.txt and extract correct Reference (either
✓
5 or 8 characters) in a loop
✓
6.
✓
Call SearchLeavers() with Reference (after attempted extraction) in a
✓
loop
✓
7.
✓
If result is FALSE then write FileData to UpdatedList.txt in a loop
✓
8.
✓
Otherwise increment NotCopied in a loop
✓
9.
✓
Return NotCopied count
✓
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 (b)

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

Write pseudocode for the module ProcessStudentList().

The module description is repeated here for reference.

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Question 17

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

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

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

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

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

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

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

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

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

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

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

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

[9]
Topic relevance

Why this question appears here

71% 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_w19_qp_22.pdf

Keep practising this topic