huynguyencab
Member
- Joined
- Nov 11, 2011
- Messages
- 37
- Gender
- Male
- HSC
- 2012
Hi,
I've been studying SDD to fight with the HSC and I have lots of questions that I want to ask. So for those who are doing HSC, if you have any questions please post here, AND for those who did SDD before, please help us
MY question:
A valid password consists of a letter followed by four digits. F1837 is an example of a valid password.
The following algorithm was designed for checking the validity of a password. The algorithm has logic errors.
Use the password H43k21 to desk check the algorithm
I tried to desk check the algorithm but when it comes to n = 4 and n = 5 the value of valid should be false then true. However, the answer given in BOS is different. Please tell me what did I do wrong
I've been studying SDD to fight with the HSC and I have lots of questions that I want to ask. So for those who are doing HSC, if you have any questions please post here, AND for those who did SDD before, please help us
MY question:
A valid password consists of a letter followed by four digits. F1837 is an example of a valid password.
The following algorithm was designed for checking the validity of a password. The algorithm has logic errors.
Code:
1 BEGIN password_check
2 INPUT password
3 IF the length of password = 5 THEN
4 valid = true
5 ENDIF
6 IF character 1 of password is a letter THEN
7 valid = true
8 FOR n = 2 TO 5
9 IF character n of password is a digit THEN
10 valid = true
11 ELSE
12 valid = false
13 ENDIF
14 NEXT
15 ENDIF
16 PRINT ‘PASSWORD IS VALID?’, valid.
17 END
I tried to desk check the algorithm but when it comes to n = 4 and n = 5 the value of valid should be false then true. However, the answer given in BOS is different. Please tell me what did I do wrong