• Best of luck to the class of 2024 for their HSC exams. You got this!
    Let us know your thoughts on the HSC exams here
  • YOU can help the next generation of students in the community!
    Share your trial papers and notes on our Notes & Resources page
MedVision ad

HSC 2003 Q22 b) ii) (1 Viewer)

Doogsy

Member
Joined
Feb 1, 2004
Messages
76
Hi
What is the error in thius bit of code. The only thing i could think of was the 'validated = true' on line 21 but it makes no diffreence if it is there or not.
Also, when it says modify the algorithm, is it acceptable to write "Insert the following between lines 14 and 15" etc
 

smallcattle

Member
Joined
Jul 6, 2004
Messages
443
Location
blacktown
Gender
Undisclosed
HSC
2010
line 4, WHILE Switched_on will get you infinite loop..unless its being defined somewhere else which i think highly unlikely

prove me if im wrong, i just cant find another error that is relating to the logic of the algorithm
 

Premus

Member
Joined
May 21, 2004
Messages
216
Yeaps it is in line 4,
you should change line 2 to "Switched_On = True" for it to work.

"Also, when it says modify the algorithm, is it acceptable to write "Insert the following between lines 14 and 15" etc"

- Yes it is :)
 

smallcattle

Member
Joined
Jul 6, 2004
Messages
443
Location
blacktown
Gender
Undisclosed
HSC
2010
PremusDog said:
Yeaps it is in line 4,
you should change line 2 to "Switched_On = True" for it to work.

"Also, when it says modify the algorithm, is it acceptable to write "Insert the following between lines 14 and 15" etc"

- Yes it is :)
hmm i think simply by changing that line wont get the algorithm fixed, i dont know how precious HSC markers want you to correct the problem. Hope they arent like my teacher who doesnt even desk check my algorithms, she just try to locate keywords and if they exist, the algorithm works...wasted of my 30mins trying to make my algorithm perfect... :vcross:

line 2 is fine from my point of view, according to line 20, the algorithm maybe getting values from other modules, but there is not enough information to prove it.
what i'll do is assuming switched_on isnt being defined somewhere else, add Switched_on = FALSE after a successful AcceptMenuChoice
 

Seraph

Now You've done it.......
Joined
Sep 26, 2003
Messages
897
Gender
Male
HSC
N/A
mmm question is SYSTEM ON and SWITCHED ON Related

is that a typo as well??? WHILE SYSTEM ON = TRUE shouldnt it be ???

sorry havent looked at it too much just curious
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
I'd ignore this question. In my opinion it is badly worded, unclear and should never have been included in an HSC exam.

Here's my comments from last year (if you're interested)...

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
 

hornetfig

Member
Joined
Jun 27, 2004
Messages
65
Location
Sydney. oddly
Gender
Male
HSC
2003
SamD said:
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.
This was my response to this question. I had some problems with Switched_On and System On because I had taken the latter to be not so much a variable but as some intrinsic status that wasn't a variable. It seemed confusing to me at the time, however, it is not that unusual to see algorithms refer to physical states of machines in that way (ie not as a variable)
 

Owyn

Member
Joined
Feb 1, 2004
Messages
102
Location
Sydney, NSW
Gender
Male
HSC
2006
we had the same problem when we came to the conclusion that line 9 is the error. It states something along the lines of
WHILE NOT Cardinslot
cardinslot must be a variable(edit: even if its not, the errorwould still apply IMO), and there NOT is a comparative term, therefore since there is no original variable to compare Cardinslot to there will be an error. Then again thats my reasoning on why its an error, the smarter people then me said line 9 aswell, i just couldn't be bothered listening to why they thought that.
 
Last edited:

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
Owyn said:
we had the same problem when we came to the conclusion that line 9 is the error. It states something along the lines of
WHILE NOT Cardinslot
cardinslot must be a variable(edit: even if its not, the errorwould still apply IMO), and there NOT is a comparative term, therefore since there is no original variable to compare Cardinslot to there will be an error. Then again thats my reasoning on why its an error, the smarter people then me said line 9 aswell, i just couldn't be bothered listening to why they thought that.
Cardinslot is a boolean variable. Therefore if Cardinslot is false the condition becomes NOT false, which is true so the body of the loop is executed. Within the loop Cardinslot is set to true if a card is shoved in the slot. As a consequence the WHILE condition is NOT true, which is false, hence control exits the loop and processing of the transaction commences.

In isolation Lines 9-14 seem OK to me. Essentially they cause processing to wait for a card to be shoved in the slot.

As boolean variables are either TRUE or FALSE they can be used as a condition on their own. For example when processing files you commonly write WHILE NOT EOF, EOF is a boolean variable.

You can also use boolean variables to make decisions. For example:

CanVote= Age>=18

is the equivalent of:

IF Age>=18 THEN
CanVote=TRUE
ELSE
CanVote=FALSE
ENDIF

HTH
Sam
 

PoP 'n' Fresh

Poke me! I giggle!
Joined
Aug 23, 2004
Messages
193
Location
Manly
Gender
Male
HSC
2005
the error which was vigourously discussed with many intellectual people in our class (=p), was found to be the incorrect use of the varibale for the first WHILE statement, as no variable exists with a state set to true, as all booleans are false by default.
now it may be a typo, but according to the all knowledgable one, youll get all the marks for it... altho this has already been discussed above...
do do do.. la la la

edit: oh, and andrew.. your way off with that reasoning. NOT, OR, AND, are all prefectly "usable" in conjunction with control structues. just makes it more confusing to read =p
 

Doogsy

Member
Joined
Feb 1, 2004
Messages
76
thanks for your help.
I think the HSC writers should get their act together, how ambiguous questions and typos/spelling errors ever make it into the final exam is beyond me, after all the proofreading that must go on (although I think it might be lack of proof reading). They should get an outside source to do the exam, to ensure no questions are ambiguous.
 

PoP 'n' Fresh

Poke me! I giggle!
Joined
Aug 23, 2004
Messages
193
Location
Manly
Gender
Male
HSC
2005
outside source = people bribe them = cheating.... go figure
but hopefully bos wont stuff it up this time round
 

PoP 'n' Fresh

Poke me! I giggle!
Joined
Aug 23, 2004
Messages
193
Location
Manly
Gender
Male
HSC
2005
eh... good point.
how bout whoever gets freakishly high in sdd... has a completely unrelated accident... yes that will do...

just joshin
 

Ditfos

New Member
Joined
Sep 9, 2004
Messages
7
Location
Dubbo
Gender
Male
HSC
N/A
Doogsy said:
I think the HSC writers should get their act together, how ambiguous questions and typos/spelling errors ever make it into the final exam is beyond me, after all the proofreading that must go on (although I think it might be lack of proof reading).
They don't get algorithms either :p
 

hornetfig

Member
Joined
Jun 27, 2004
Messages
65
Location
Sydney. oddly
Gender
Male
HSC
2003
Ditfos said:
They don't get algorithms either :p
no joke about it, it is [in all likelihood, but this is pure conjecture] true - they don't understand. The markers would be in a worse situation - they are your SDD teachers...
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top