• 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

Algorithm for marking :) (1 Viewer)

Glide

Member
Joined
Oct 13, 2003
Messages
103
Question 22 E 2002 paper

2002 Paper here

Code:
BEGIN CostOfTickets(UserDest,NumSingle,NumReturn)

Set FoundDest as Boolean
Set TotalFare as Integer
Set Index as Integer
FoundDest = False
TotalFare = 0
Index = 1
WHILE destination(Index) < 101 AND FoundDest = False
	IF Destination(Index).station = UserDest THEN
		TotalFare =  Destination(Index).Fullsingle * NumSingle
		TotalFare = TotalFare + Destination(Index).FullReturn * NumReturn
		FoundDest = True
	END IF
Index = Index + 1
ENDWHILE
Display TotalFare

END CostOfTickets
Please rip it apart :)
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
Bloody good answer!!!! However....

-Loop condition is wrong, should be Index<101 not Destination(Index)<101, so you lose a mark.

A few other trivial things that wouldn't lose marks...

-You don't need to specify the type of your variables in an algorithm, but don't sweat, losing marks for this would be super slack!! Just be careful, set is often used for assignment in pseudocode.

-What happens if the destination is not found in the array? Currently you just display 0, some sort of error message maybe more appropriate. (I doubt you'd lose a mark, but who knows!)

-This is really trivial, nit picky stuff. In the context of the whole application this routine would likely be a function. However you display the TotalFare, seems more logical to me to return the TotalFare. you could write 'CostOfTickets=TotalFare' or 'Return TotalFare as CostOfTickets' or similar.

Excellent work

HTH
Sam
 

-X-

Member
Joined
Aug 10, 2003
Messages
481
Gender
Undisclosed
HSC
N/A
Its corret but u still have to display the fair information as stated in the question.
Part of the algorithm is to conduct a search of an array of records containing the
single full fare and return full fare for each destination. The search needs to
extract fare information for the destination station selected by the train traveller.
ie display price of return tickets, single tickets etc....

edit: woops samd answered it.
 
Last edited:

Winston

Active Member
Joined
Aug 30, 2002
Messages
6,128
Gender
Undisclosed
HSC
2003
Originally posted by -X-
Its corret but u still have to display the fair information as stated in the question.

ie display price of return tickets, single tickets etc....
Ahuh

just a simple PRINT statement at the end ;)
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
I disagree, the question says....
"The search needs to EXTRACT fare information for..."

I can't see where it says to display it, in fact you don't have to display anything. The question says "calculate the cost of the tickets", to me this means the total cost of the tickets as that's what it says TotalFare stands for.
 

Glide

Member
Joined
Oct 13, 2003
Messages
103
Wow thanks for the feedback guys!

This was in the marking guidelines 'Good responses obtained user input, searched the entire array for the destination and
calculated the required fare.'
Like SamD said, I should have returned the value back and constructed it as a proper function rather than displaying the total cost :)

I wasnt too sure about the assignment of actual data types, I've seen some examples and multiple choice questions set by the BOS that has 'Set Blah as empty string'.

Thanks for the pointers!
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
Originally posted by Glide
I wasnt too sure about the assignment of actual data types, I've seen some examples and multiple choice questions set by the BOS that has 'Set Blah as empty string'.
I know what you mean Glide, however be careful with your use of the word assignment, it could be misconstrued. An assignment statement is used to shove some data in a variable, not declare its type. ie. 'Set Blah to empty string' means shove an empty string into the variable Blah. If your talking about declaring a variable to be of a particular type, it's best not to use the word assignment.
 

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

Top