You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before, The task 1 Train Journey Display algorithm had an IF statement in the FOR loop to check if the tickets were available or not. If tickets were not available it would PRINT that the Train for that hour is closed.
FOR index <- 0 TO 3
IF UpSeats[index] != 0
THEN
PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])
ELSE
PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Closed!")
ENDIF
IF DownSeats[index] != 0
THEN
PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Remaining Tickets: ", DownSeats[index])
ELSE
PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Closed!")
ENDIF
NEXT index
But knowing that this is the first time the Train Journey Display is being shown, and there had not been any bookings. We can remove the IF statements and the print statement for showing the Train is closed from the task 1 because there is no way that a train is going to be closed when the program has just started.
The improved algorithm for task 1 looks like this:
FOR index <- 0 TO 3
PRINT ("Train No: ", index, "| Train Departure Hour: ", UpTime[index], "| Remaining Tickets: ", UpSeats[index])
PRINT ("Train No: ", index, "| Train Return Hour: ", DownTime[index], "| Remaining Tickets: ", DownSeats[index])
PRINT "---------"
NEXT index
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Before, The task 1 Train Journey Display algorithm had an IF statement in the FOR loop to check if the tickets were available or not. If tickets were not available it would PRINT that the Train for that hour is closed.
But knowing that this is the first time the Train Journey Display is being shown, and there had not been any bookings. We can remove the IF statements and the print statement for showing the Train is closed from the task 1 because there is no way that a train is going to be closed when the program has just started.
The improved algorithm for task 1 looks like this:
link to the commit:
b6f69d8
Train Journey Display algorithm in Task 2 remain unchanged.
Beta Was this translation helpful? Give feedback.
All reactions