What were the two logic errors in 23(b)(i)? (1 Viewer)

Maximus

Decimus Meridius
Joined
Jan 27, 2004
Messages
97
Location
Balmain
Gender
Male
HSC
2004
The only error-type thing I found is that the program only seems to print out one seat location instead of all of them, so I changed the code to fix that. What were these 2 errors supposed to be?
 

milton

Member
Joined
Oct 30, 2004
Messages
107
Location
Westmead
Gender
Male
HSC
2006
i didnt really have time to write it down, but i believe that you need to reset available = false after each seat is considered, or else you just get available = true all the way. you also needed to put print array(row,seat) somewhere in the 2 nested loops, so that it will print teh seat if it is available
 

Maximus

Decimus Meridius
Joined
Jan 27, 2004
Messages
97
Location
Balmain
Gender
Male
HSC
2004
Hehe, that's what I did, actually I removed the available variable completely. As long as you put the statement inside the loops it seems to be redundant.
 

Wild Dan Hibiki

teh sex0r
Joined
Feb 28, 2004
Messages
649
Gender
Undisclosed
HSC
2004
crap, i said that once seat = 11 the loop gets skipped, and after the loops only the last available seat is printed. so i guess there were more than one logic error
 

helloyo

Member
Joined
Oct 10, 2004
Messages
42
i said that the line that set available to true was wrong because as soon as one seat is available they are all considered available after it. and the code after the loops would only show the status of the last seat. so i took out that last bit of code, and put in a print statement instead of the available = true statement.
 

andrew12345aus

New Member
Joined
Apr 6, 2004
Messages
3
Gender
Undisclosed
HSC
N/A
the 2 errors i but down were the one as above the (the print array needed to go in the loop) and also that after the program finished a row of seats it didn't seat the seat number back to one.
 

acmilan

I'll stab ya
Joined
May 24, 2004
Messages
3,989
Location
Jumanji
Gender
Male
HSC
N/A
The other error was the when it printed, it printed array(row,seat), but this would print "unsold", not the actual row and seat number. The print command had to be changed to something like print row, seat. This error didnt have to be mentioned if you already had 2 but it would have had to be fixed in the second part when writing the algorithm
 

JayWalker

Member
Joined
Mar 19, 2004
Messages
401
Location
Sydney
Gender
Male
HSC
2004
Well actually there were 3 logical errors,
One was that once the seat got to 11, all the rest of the seats were unavailable.
Another was relating to this, but the seat wasnt reset to 0.. which was another error relating to the previous.

And the other one was the rows....
 

Vuki

Member
Joined
Apr 4, 2004
Messages
84
Gender
Male
HSC
2004
PRINT (row, seat) did not print unsold acmilan.

Unsold = the value is was assigned prevouis to the algorithm (not involved in the process we had to do). If it was unsold, you would then print (row, seat). Ie the index numbers in the array such as: PRINT (3, 5) would print row 3 seat 5.
 

phizz

aka: Philly Cheese
Joined
Jul 4, 2004
Messages
131
Location
Wauchope (port mac')
Gender
Male
HSC
2004
The two I found, same as many above, was:
The program required to print a list of avalible seats, including their indexes. All this algorithm did was flag if there was one avalible or not. and it would only print whether seat(9,11) was sold or unsold. This would also cause an array out of range error.

It would print (giving exception to the out of range error):

"unsold"

It should print:

"Seat: 7, row 8. Seat: 7, row 5." ect...
 

acmilan

I'll stab ya
Joined
May 24, 2004
Messages
3,989
Location
Jumanji
Gender
Male
HSC
N/A
Vuki said:
PRINT (row, seat) did not print unsold acmilan.

Unsold = the value is was assigned prevouis to the algorithm (not involved in the process we had to do). If it was unsold, you would then print (row, seat). Ie the index numbers in the array such as: PRINT (3, 5) would print row 3 seat 5.
print array(row,seat) would print "unsold", this was what was in the algorithm they gave and hence an error
print (row,seat) would print the row and the seat eg (2,3) and this is what had to be used to replace the above and is correct
 

sladehk

le random
Joined
Jul 26, 2004
Messages
1,000
Gender
Undisclosed
HSC
2006
once through the first row, it would go through only the 10th seat of each row
it printed unsold- coz array(row, seat) = "unsold" or "sold"<- i'm guessing
it would only print whether row 8 seat 10 was avaliable or not instead of all

how did you guys fix it?
i totally changed the code,
took out line 14-16 i think and put the print "row:" + row + "seat:" + seat + "- unsold" inside interior loop
put seat = 1 in side the first loop
 

Owyn

Member
Joined
Feb 1, 2004
Messages
102
Location
Sydney, NSW
Gender
Male
HSC
2006
I'm quite sure if you answered 23i you cant get it wrong, there where just so many errors in that code that your bound to have picked up atleast 2. However if like me you used that code to help make 23ii, i think you'll lose some marks for not correcting all errors, such as the increment one which i missed, or the print array(row, seat). At the time when i got my 2 i kinda assumed that was it, so figured the rest of the code could be used. Shame, would have been better completely rewritting it :( lalallala it over happy :)
 

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

Top