Here it is....
Hi everyone,
Some comments on 22(b)(ii) in the SDD HSC.
Exam committee members, please take these comments as constructive criticism. I just feel for the students who had to answer this question and for the poor buggers who've got to mark it!
Anyway here's my comments on it...
1. Firstly, just prior to part (ii) the question says "The system has a logic error", the "system" not necessarily the algorithm, although most would assume the logic error is in the algorithm. Then in part (ii) it says "Locate the error...", we assume "THE error" is the logic error previously referred to, but maybe not! I know this is somewhat pedantic, however maybe it means consideration should be given to awarding marks for locating/correcting any type of error?
2. Line 4 is an error (but is it in reality a typo?) still it should be WHILE System_on. There are two possible effects, either you never enter the loop at all (if Switched_on is false) or processing continues infinitely (if Switched_on is True). In either case it results in bodgy processing, so it is a logic error. If this is the intended error then it's pretty trivial for 4 marks, it's a shame it's in the question as many students will have spotted it and just waffled on about it. Surely students will get marks for it... as the question says locate THE error. (Also if you've gotta READ this value at the end of the loop then surely you'd need to READ it before the loop as a priming READ).
3. Line 21 is redundant, but this does not cause a logic error.
4. Line 5 has an extra space. This line is pointless anyway, as the CustomerNumber originates from the AcceptCardDetails call, so not a logic error. Also why is Validated and StoredPassword initialised? Both these originate from calls. When implemented in code you need to declare them but who cares what their intial values are?
5. The mainline does not implement the structure chart correctly. In the pseudocode AcceptMenuChoice is executed in response to a decision based on the value of Validated, yet no decision diamond appears on the structure chart. The structure chart indicates that the Validated control parameter is sent to the AcceptMenuChoice routine, which it is. The implication being that it is used within the AcceptMenuChoice routine to determine if menu choices can indeed be processed. Is this a logic error? It all still works as intended so I guess not, but there is redundant processing. However, the logic in the pseudocode does not match the logic in the structure chart, so in this sense it is a logic error (or at least some sort of error),its better than nothing so I'd hope some portion of the marks would be awarded.
6. I suspect this could just be 'THE logic error' the examiners were after, but I'm not a mind reader. Imagine the ATM is turned on (Switched_on or System_on, whatever), execution has now entered the outside loop. CardInSlot is set to FALSE, so we enter the inside loop. The only way you can ever get out of this 'WHILE NOT CardInSlot loop is to shove in a card. So the only way to get the thing to turn off is to switch it off (whatever that means!) then shove a card in the card slot, this gets you out of the 'WHILE NOT CardInSlot' loop, before System_on (or Switched_on) is read as false. This is weird stuff, as it seems logical to assume System_on or Switched_on refers to the power, if you turn the power off then surely everything stops regardless of the algorithm! (Maybe there's battery, so the current transaction can be completed, who knows!) If this is "THE error" then it's a bit obtuse, I can think of heaps of ways to include a logic error in the algorithm, and this wouldn't be one of them.
So how do kids fix all this mess? Here's one possible solution that, I think, fixes all of the above...
Code:
BEGIN ATM System
READ System_on
WHILE System_on
IF Card is located in cardslot THEN
AcceptCardDetails(CustomerNumber,StoredPassword)
AcceptAndValidatePassword(StoredPassword,Validated)
AcceptMenuChoice(Validated,CustomerNumber)
ENDIF
READ System_on
ENDWHILE
END
Regards,
Sam