0% found this document useful (0 votes)
42 views

Robust and Secure Programming Question Paper

The document contains test plans and algorithms for user login and password validation. It includes pseudocode for login validation with usernames and passwords in arrays, suggestions to improve it, test data for a input validation loop, and an algorithm for password creation.

Uploaded by

Jaida Aborah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Robust and Secure Programming Question Paper

The document contains test plans and algorithms for user login and password validation. It includes pseudocode for login validation with usernames and passwords in arrays, suggestions to improve it, test data for a input validation loop, and an algorithm for password creation.

Uploaded by

Jaida Aborah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Q6.

Part of a program written in VB.Net is shown below.

Dim validChoice As Boolean


Dim choice As Integer
validChoice = False
While validChoice = False
Console.Write("Enter your choice [1 - 10] ")
choice = Console.ReadLine()
If choice >= 1 And choice <= 10 Then
validChoice = True
Else
Console.WriteLine("Invalid choice")
End If
End While
Console.WriteLine("Valid choice")

Complete the following test plan for the code shown above.

Test type Test data Expected result

Valid choice message


Normal data 5
displayed

Invalid data

Boundary
data
(Total 2 marks)

Q7.
The algorithm below, expressed in pseudo-code, allows three users to log in to a
computer program with individual usernames and passwords.

• For this algorithm, array indexing starts at 0.


• Line numbers are included, but are not part of the algorithm.

01 userlist ← [ 'Rachel', 'Sam', 'Tracey' ]


02 passlist ←
[ '49Class', 'Smile', 'b1K3' ]
03 REPEAT
04 OUTPUT 'Enter Username'
05 username ← USERINPUT
06 OUTPUT 'Enter Password'
07 password ← USERINPUT
08 validlogin ← False
09 FOR usernum ← 0 TO
2
10 IF username = userlist[usernum]
11 AND password = passlist[usernum] THEN
12 validlogin ← True
13 ENDIF
14 ENDFOR
15 UNTIL validlogin = True
16 OUTPUT 'Login Successful'

Page 8 of 11
The valid usernames and passwords are listed below.

Username Password

Rachel 49Class

Sam Smile

Tracey b1K3

(a) Shade in one lozenge in each row of the table below to indicate the most
appropriate data type to use for each listed Variable from the algorithm, when the
algorithm is implemented in a programming language.

Most appropriate data type (shade one lozenge per row)

Variable Integer Real Boolean Character String


password

validlogin

usernum

(3)

(b) It is suggested that line 09 of the algorithm is replaced with the following line:

FOR usernum ← 0 TO LEN(userlist)

The function LEN returns the number of items that are stored in the array that is
passed to it as a parameter.

Explain why using the LEN function would make the algorithm more flexible and why
the suggested replacement line would not work as it is.
as array indexing begins at 0,
___________________________________________________________________
must change line to FOR usernum
<= 0 TO LEN(userlist) - 1,
___________________________________________________________________
otherwise index would try to
access an element outside of the
___________________________________________________________________
array. LEN function allows to
iterate over arrays of varying
___________________________________________________________________
length
___________________________________________________________________

___________________________________________________________________
(3)

(c) It is suggested that lines 08 to 14 of the algorithm are replaced with the following
lines:

FOR usernum ← 0 TO 2
IF username = userlist[usernum]
AND password = passlist[usernum] THEN
validlogin ← True
ELSE
validlogin ← False

Page 9 of 11
ENDIF
ENDFOR

Explain why making this replacement would mean that the algorithm no longer
worked.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)

(d) State which of the three passwords listed in the table above is the least secure and
explain why this is the case.
Smile
Which password:____________________________________________________

Why least secure:___________________________________________________


only uses letters, no numbers or
___________________________________________________________________
special characters used
___________________________________________________________________
(2)
(Total 11 marks)

Q8.

The pseudocode below is written to make sure that the user enters a value within a given
range.

inp ← USERINPUT
WHILE inp ≤ 0 OR inp ≥ 10
OUTPUT "not in range"
inp ← USERINPUT
ENDWHILE

(a) (i) Tick the set of test data that is the most appropriate to check that the code
works as expected.

Tick one
Test data
box
−1, 0, 9, 10

0, 1, 10, 11

−1, 0, 10, 11

Page 10 of 11
0, 1, 9, 10

(1)

(ii) Why is the set of test data that you have chosen in part (i) likely to be enough
to show that the code above works as expected?
only tests boundary data
______________________________________________________________

______________________________________________________________
(1)

(b) Develop an algorithm using pseudocode or a flowchart that asks the user to create
a new password.

The algorithm should:

• get the user to enter a password


• get the user to re-enter the password
• repeat the two bullet points above until both entered passwords are identical
• output "password created" when they are identical.

pass1 <= USERINPUT


___________________________________________________________________
pass2 <= USERINPUT
WHILE pass1 != pass2
___________________________________________________________________
pass1 <= USERINPUT
pass2 <= USERINPUT
___________________________________________________________________
OUTPUT 'password created'
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(5)

(c) State two possible weaknesses of the passwords that this algorithm would accept.
password that could be too short
1. _________________________________________________________________

___________________________________________________________________

allows passwords that are the


2. _________________________________________________________________
same as the username
___________________________________________________________________
(2)
(Total 9 marks)

Page 11 of 11

You might also like