Past-paper question · 2017 May-June · Paper 23 · Q6(a)

Question 6(a) 2017 · May-June · Paper 23 · 10 marks

Original past-paper question for 6(A)
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 mark-scheme answer for 6(A)

Official answer for Question 6

Part (a)

✓
Pseudocode solution included here for development and clarification of

Question 10

✓
mark scheme.
✓
Programming language solutions appear in the Appendix.
✓
FUNCTION ValidatePassword(InString : STRING) RETURNS
✓
BOOLEAN
✓
DECLARE LCaseChar, UCaseChar, NumChar, n : INTEGER
✓
DECLARE NextChar : CHAR
✓
DECLARE ReturnFlag : BOOLEAN
✓
ReturnFlag ← TRUE
✓
LCaseChar ← 0, UCaseChar ← 0, NumChar ← 0
✓
FOR n ← 1 TO LENGTH(InString)
✓
NextChar ← MID(InString,n,1)
✓
IF NextChar > = 'a' AND NextChar < = 'z'
✓
THEN
✓
LCaseChar ← LCaseChar + 1
✓
ELSE
✓
IF NextChar > = 'A' AND NextChar < = 'Z'
✓
THEN
✓
UCaseChar ← UCaseChar + 1
✓
ELSE
✓
IF NextChar > = '0' AND NextChar < = '9'
✓
THEN
✓
NumChar ← NumChar + 1
✓
ELSE
✓
ReturnFlag ← False
✓
//invalid
✓
character
✓
ENDIF
✓
ENDIF
✓
ENDIF
✓
ENDFOR
✓
IF Not (LCaseChar>=2 AND UCaseChar>= 2 AND NumChar>= 3)
✓
THEN
✓
ReturnFlag ← FALSE
✓
ENDIF
✓
RETURN (ReturnFlag)
✓
ENDFUNCTION
✓
1 mark for each of the following:
✓
1.
✓
Correct Function heading and ending
✓
2.
✓
Declaring three counter variables (upper, lower, numeric)
✓
3.
✓
Initialising counters
✓
4.
✓
Correct loop
✓
5.
✓
Picking up NextChar from InString
✓
6.
✓
Check and count number of lower case
✓
7.
✓
Check and count number of upper case
✓
9608/23
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s17_ms_23.pdf →

Show text version of question

Question 6

Part (a)

Question 6

A multi-user computer system makes use of passwords.

To be valid, a password must comply with the following rules:

  • at least two lower-case alphabetic characters
  • at least two upper-case alphabetic characters
  • at least three numeric characters
  • alpha-numeric characters only
A
function, ValidatePassword, is needed to check that a given password follows these rules.

This function takes a string, Pass, as a parameter and returns a Boolean value:

  • TRUE if Pass contains a valid password
  • FALSE otherwise.

Part (a)

Write program code to implement the new function ValidatePassword.

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 11

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.............................................................................................................................................[10]

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

Keep practising this topic