Past-paper question · 2021 May-June · Paper 23 · Q5(b)

Question 5(b) 2021 · May-June · Paper 23 · 4 marks

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

Official answer for Question 5

Part (b)

✓
One mark for check plus one for corresponding test data example.

Question 4

✓
Test data must be invalid to prove that the check is working.
✓
Telephone number:
✓
•
✓
Length check // Check that the telephone number string is at least six
✓
characters
✓
e.g. number of "127"
✓
OR
✓
•
✓
Check it is a number // Check that the telephone number string only
✓
contains characters from ‘0’ to ‘9’
✓
e.g. number of "12A"
✓
Template:
✓
•
✓
Check it is a number in range 1 to 5 //Check that the template string
✓
only contains characters from ‘1’ to ‘5’
✓
e.g. template of "127"
✓
OR
✓
•
✓
Check that there are enough characters in the TelNum string so that
✓
the template can be applied
✓
e.g. Telnum = "123456", Template = "66"
✓
9608/23
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s21_ms_23.pdf →

Show text version of question

Question 5

Part (b)

Question 5

A program stores a contact list of telephone numbers. Each telephone number is stored as a

string of six or more numeric characters.

Before they are displayed, number strings are formatted to make them easier to read. This involves forming the characters into groups, separated by the space character.

The maximum length of a number group is five characters.

Different numbers may have different groupings. A template string is used to define the grouping.

For example:

Number string Template string Formatted string

For the first row, template "53" results in a formatted string comprising:

  • the first five characters in the first group
  • a space character
  • the next three characters in the second group
  • a space character
  • the remaining characters from the number string.

Part (b)

The function GroupNum() is to be extended to include parameter checking.

State one check that could be applied to each parameter. Give an example of test data that could be used to demonstrate that each check identifies invalid data.

The type of check must be different for each parameter.

Telephone number check .........................................................................................................

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

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

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

Test data ...................................................................................................................................

Template check .........................................................................................................................

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

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

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

Test data ...................................................................................................................................

[4]

Question 15

Question 16

Topic relevance

Why this question appears here

71% assigned-topic match · Programming › Structured programming

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

Keep practising this topic