Past-paper question · 2018 May-June · Paper 22 · Q5(d)

Question 5(d) 2018 · May-June · Paper 22 · 10 marks

Original past-paper question for 5(D)
Original past-paper question for 5(D)
Original past-paper question for 5(D)
Original past-paper question for 5(D)
Reveal official mark-scheme answer Official mark-scheme answer for 5(D)

Official answer for Question 5

Part (d)

✓
‘Pseudocode’ solution included here for development and clarification of
✓
mark scheme.
✓
Programming language solutions appear in the Appendix.
✓
PROCEDURE
✓
OutputLowestScore()
✓
DECLARE
✓
FileData, FileMembershipNumber : STRING
✓
DECLARE
✓
FileScore, LowestScore : INTEGER
✓
DECLARE
✓
LowestScoreDate, MembershipNumber : STRING
✓
MembershipNumber ← GetNumber()
✓
OPENFILE "ScoreDetails.txt" FOR READ
✓
LowestScore ← 100
✓
WHILE NOT EOF("ScoreDetails.txt")
✓
READFILE "ScoreDetails.txt", FileData
✓
FileMembershipNumber ← LEFT(FileData, 4)
✓
IF FileMembershipNumber = MembershipNumber
✓
THEN
✓
FileScore ← INT(RIGHT(FileData,2))
✓
IF FileScore < LowestScore
✓
THEN
✓
LowestScore ← FileScore
✓
LowestScoreDate ← MID(FileData(5,6))
✓
ENDIF
✓
ENDIF
✓
ENDWHILE
✓
OUTPUT ("The lowest score was " & LowestScore & " on "
✓
& _
✓
LowestScoreDate)
✓
CLOSEFILE("ScoreDetails.txt ")
✓
ENDPROCEDURE
✓
1 mark for each of the following:

Question 1

✓
Declare variables to store LowestScore as INTEGER and FileData
✓
as STRING (commented in Python) (variable names may be different)
✓
2 Function call GetNumber() for membership number
✓
3 Initialisation of LowestScore to 99 or above
✓
4 Open file in READ mode
✓
5 Loop until EOF()
✓
6 Read a line from the file in a loop
✓
7 Use of substring operations to extract at least one data item
✓
8 Compare the membership numbers
✓
9 Convert score to INTEGER
✓
10 Compare and assign (if appropriate) new value to LowestScore
✓
11 Output the lowest score message including lowest score and date
✓
(outside the loop)
✓
12 Close the file
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s18_ms_22.pdf →

Show text version of question

Question 5

Part (d)

Question 5

A golf club holds information about its members. When a member completes a round of golf, their

score is stored along with their membership number and the date of the round.

A
program is to be written to store and process the score information. The information to be stored

is formed into a string as follows:

<MembershipNumber><Date><Score>

Part (d)

The program designer decides to store the strings from part

Part (a)

in a text file,

ScoreDetails.txt

Each string is formatted as follows:

<MembershipNumber><Date><Score>

  • MembershipNumber is a four-digit numeric string between "1111" and "9999".
  • Date is a six-digit numeric string in the format DDMMYY, for example "040716".
  • Score is a two-digit numeric string in the range "50" to "99".
A
procedure OutputLowestScore() is required to output the lowest score for an individual

member.

Assume that there is at least one string stored for each member.

The program needs a procedure, OutputLowestScore(), to process the ScoreDetails.txt file and output the lowest score for an individual member.

1. Use the GetNumber() function to obtain a valid membership number. 2. Search the ScoreDetails.txt file for the lowest score for that member. 3. Output a message giving the lowest score for that member and the date of the round. For example: "The lowest score was 66 on 300917"

Write program code for the OutputLowestScore() procedure.

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

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

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

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

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

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

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

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

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

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

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

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

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

Question 13

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[10]

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

Keep practising this topic