Past-paper question · 2017 May-June · Paper 21 · Q6(b)(iii)

Question 6(b)(iii) 2017 · May-June · Paper 21 · 2 marks

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

Official answer for Question 6

Part (b)

(iii)

✓
•
✓
Testing may be carried out before the modules are developed // not

Question 2

✓
ready for full testing
✓
•
✓
Module stubs contain simple code to provide a known response //
✓
temporary replacement for a called module
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Programming Solutions
✓
Programming Code Example Solutions
✓
Q5 : Visual Basic
✓
Sub SearchFile()
✓
Dim FileData As String
✓
Dim SearchID As String
✓
Dim ArrayIndex As Integer
✓
ArrayIndex = 1
✓
FileOpen(1, "LoginFile.txt", OpenMode.Input)
✓
SearchID = Console.Readline()
✓
Do While Not EOF(1)
✓
FileData = LineInput(1)
✓
If SearchID = LEFT(FileData, 5) Then
✓
LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4)
✓
LoginEvents(ArrayIndex, 2) = Right(Filedata, 14)
✓
ArrayIndex = ArrayIndex + 1
✓
End If
✓
Loop
✓
FileClose(1)
✓
End Sub
✓
Alternative:
✓
Sub SearchFile()
✓
Dim FileData As String
✓
Dim SearchID As String
✓
Dim ArrayIndex As Integer
✓
Dim MyFile As System.IO.StreamReader
✓
ArrayIndex = 1
✓
MyFile = Mycomputer.FileSystem.OpenTextFileReader("Loginfile.txt")
✓
SearchID = Console.Readline()
✓
Do While MyFile.Peek < > -1
✓
FileData = MyFile.Readline()
✓
If SearchID = LEFT(FileData, 5) Then
✓
LoginEvents(ArrayIndex, 1) = Mid(Filedata, 6, 4)
✓
LoginEvents(ArrayIndex, 2) = Right(Filedata, 14)
✓
ArrayIndex = ArrayIndex + 1
✓
End If
✓
Loop
✓
MyFile.Close
✓
End Sub
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Q5 : Pascal
✓
Procedure SearchFile();
✓
var
✓
FileData
✓
:
✓
String;
✓
var
✓
SearchID
✓
:
✓
String;
✓
var
✓
ArrayRow
✓
:
✓
Integer;
✓
Var
✓
MyFile
✓
:
✓
Text;
✓
Begin
✓
ArrayRow := 1;
✓
Assign(MyFile, "Loginfile.txt");
✓
Reset(MyFile);
✓
Readln(SearchID);
✓
While NOT EOF(MyFile) do
✓
Begin
✓
Readln(MyFile, FileData)
✓
IF SearchID = LeftStr(FileData,5) then
✓
Begin
✓
LoginEvents[ArrayRow,1] = Copy(FileData,6,4);
✓
LoginEvents[ArrayRow,2] = Rightstr(FileData,14);
✓
ArrayRow = ArrayRow + 1
✓
End;
✓
End;
✓
Close(MyFile);
✓
End.
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2017
✓
PUBLISHED
✓
Q5 : Python
✓
def SearchFile():
✓
# FileData : STRING
✓
# ArrayRow : INTEGER
✓
# SearchID : STRING
✓
ArrayRow
✓
= 0
✓
MyFile =
✓
open("Loginfile.txt", 'r')
✓
SearchID
✓
= input()
✓
FileData
✓
= MyFile.readline()
✓
While FileData != ""
✓
If SearchID = = FileData[:5]
✓
#First 5 characters
✓
LoginEvents[ArrayRow][1] = FileData[5:9]
✓
#next 4 characters
✓
LoginEvents[ArrayRow][2] = FileData[-14:]
✓
#last 14 characters
✓
ArrayRow = ArrayRow + 1
✓
FileData = MyFile.readline()
✓
myFile.close()
✓
return()
✓
Alternative:
✓
def SearchFile():
✓
# FileData : STRING
✓
# ArrayRow : INTEGER
✓
# SearchID : STRING
✓
ArrayRow = 0
✓
Myfile = open("Loginfile.txt", 'r')
✓
SearchID = input()
✓
For FileData in MyFile
✓
IF SearchID = = FileData[:5]
✓
#First 5 characters
✓
LoginEvents[ArrayRow][1] = FileData[5:9]
✓
#next 4 characters
✓
LoginEvents[ArrayRow][2] = FileData[-14:]
✓
#last 14 characters
✓
ArrayRow = ArrayRow + 1
✓
MyFile.close()
✓
return()

Mark scheme 9608_s17_ms_21.pdf →

Show text version of question

Question 6

Part (b)

(iii)

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.

(iii)

A program consisting of several modules may be tested using a process known as

stub testing.

Explain this process.

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

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

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

.......................................................................................................................................[2]

Question 14

Appendix Built-in functions (pseudocode) In each function, if the function call is not properly formed, the function returns an error.

MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING

returns string of length y starting at position x from ThisString. Example: MID("ABCDEFGH", 2, 3) returns string "BCD"

LENGTH(ThisString : STRING) RETURNS INTEGER

returns the integer value representing the length of string ThisString. Example: LENGTH("Happy Days") returns 10

LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING

returns leftmost x characters from ThisString. Example: LEFT("ABCDEFGH", 3) returns string "ABC"

RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING

returns rightmost x characters from ThisString. Example: RIGHT("ABCDEFGH", 3) returns string "FGH"

LCASE(ThisChar : CHAR) RETURNS CHAR

returns the character value representing the lower case equivalent of ThisChar. If ThisChar is not an upper-case alphabetic character then it is returned unchanged. Example: LCASE('W') returns 'w'

MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER

returns the integer value representing the remainder when ThisNum is divided by ThisDiv. Example: MOD(10,3) returns 1

DIV(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER

returns the integer value representing the whole number part of the result when ThisNum is divided by ThisDiv. Example: DIV(10,3) returns 3

Operators (pseudocode)

Operator Description Concatenates (joins) two strings. & Example: "Summer" & " " & "Pudding" produces "Summer Pudding" Performs a logical AND of two Boolean values. AND Example: TRUE AND FALSE produces FALSE Performs a logical OR of two Boolean values. OR Example: TRUE OR FALSE produces TRUE

Question 15

Question 16

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

91% assigned-topic match · Data types and structures › Data types and records

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

Keep practising this topic