Past-paper question · 2018 May-June · Paper 21 · Q5(c)

Question 5(c) 2018 · May-June · Paper 21 · 9 marks

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

Official answer for Question 5

Part (c)

✓
'Pseudocode' solution included here for development and clarification of mark

Question 9

✓
scheme.
✓
Programming language solutions appear in the Appendix.
✓
PROCEDURE AddNewScores()
✓
DECLARE
✓
FileData : STRING
✓
DECLARE
✓
ScoreDate : STRING
✓
DECLARE
✓
MembershipNumber : STRING
✓
DECLARE
✓
Score : STRING
✓
OUTPUT "Input the date for the scores"
✓
INPUT ScoreDate
✓
OPENFILE "ScoreDetails.txt" FOR APPEND
✓
OUTPUT "Input the Membership number"
✓
INPUT MembershipNumber
✓
WHILE NOT MembershipNumber = ""
✓
OUPUT "Input the score"
✓
INPUT Score
✓
WHILE (INT(SCORE) < 50) OR (INT(SCORE) > 99)
✓
OUTPUT "Input a valid score from 50 to 99"
✓
INPUT Score
✓
ENDWHILE
✓
FileData = MembershipNumber & ScoreDate & Score
✓
WRITEFILE "ScoreDetails.txt", FileData
✓
OUTPUT "Input the Membership number"
✓
INPUT MembershipNumber
✓
ENDWHILE
✓
CLOSEFILE("ScoreDetails.txt")
✓
ENDPROCEDURE
✓
1 mark for each of the following:

Question 1

✓
Declare MembershipNumber as STRING and Score as INTEGER /
✓
STRING (commented in Python)

Question 2

✓
Prompt and Input of ScoreDate

Question 3

✓
Open ScoreDetails.txt in APPEND mode

Question 4

✓
Prompt and Input of MembershipNumber in a loop

Question 5

✓
(Outer) loop terminated when MembershipNumber = ""

Question 6

✓
Input Score and loop until valid

Question 7

✓
Form the text string from the three variables

Question 8

✓
Write the text string to the file

Question 9

✓
Close the file
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s18_ms_21.pdf →

Show text version of question

Question 5

Part (c)

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.

Part (c)

The information is stored in a text file, ScoreDetails.txt. The format of each line of the

text file is as follows:

<MembershipNumber><Date><Score>

  • MembershipNumber is a four-digit numeric string.
  • Date is a six-digit numeric string in the format DDMMYY
  • Score is a two-digit numeric string in the range "50" to "99".
A
procedure, AddNewScores(), is being developed. This will allow the user to enter scores

for several members on a particular date.

The procedure, AddNewScores(), will perform the following actions:

1. Prompt for the date of the scores. 2. Input the date of the scores. 3. Prompt for the membership number. 4. Input the membership number. 5. If the membership number is an empty string then end the procedure. 6. Prompt for the score. 7. Input the score. 8. Validate the score. 9. If the validation fails then repeat from step 6. 10. Form a text string from the data and write this to the ScoreDetails.txt file. 11. Repeat from step 3.

Question 11

Write program code for the AddNewScores() 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

......................................................................................................................................................[9]

Question 12

Topic relevance

Why this question appears here

82% 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_s18_qp_21.pdf

Keep practising this topic