GREEN RED
END IF NEXT count
PRINT “What time would you like to go down the mountain?”
INPUT time_down
WHILE time_down < time_up OR time_down <> 1000 OR time_down <> 1200 OR time_down <> 1400 OR time_down <> 1600
INPUT “Wrong time entered. It should be greater than the time chosen for going up and only be either 10, 12, 14 or 16”, time_down
END WHILE
FOR count 1 TO 4
IF time_down = time_down[count] THEN index_down count
END IF NEXT count
PRINT “How many tickets would you like to buy? Every tenth ticket is free for groups of between ten and eighty passengers inclusive.”
PRINT “The tickets available for the train going up is: “, tickets_up[index_up]
PRINT “The tickets available for the train going back down is: “, tickets_down[index_down]
INPUT num_tickets
WHILE num_tickets <= 0 OR num_tickets > tickets_up[index_up] OR num_tickets >
tickets_down[index_down]
INPUT “There are not enough tickets available. Please choose any available number of tickets as displayed above”, num_tickets
END WHILE
IF num_tickets >= 80 THEN discount 8 * ticket_cost
one_way_cost (ticket_cost * num_tickets) – discount ELSE IF num_tickets >= 10 THEN
one_way_cost ticket_cost * (num_tickets – (num_tickets DIV 10)) ELSE
one_way_cost ticket_cost * num_tickets END IF
tickets_up[index_up] tickets_up[index_up] – num_tickets
tickets_down[index_down] tickets_down[index_down] – num_tickets passengers_up[index_up] passengers_up[index_up] + num_tickets
passengers_down[index_down] passengers_down[index_down] + num_tickets money_up[index_up] money_up[index_up] + one_way_cost
money_down[index_down] money_down[index_down] + one_way_cost
PRINT “Welcome to Train Reservation System”
PRINT “The following is a table of the train times and number of train tickets available:”
PRINT “The train departure times and tickets available for four journeys going up are:”
FOR count 1 TO 4
IF tickets_up[count] = 0 THEN
PRINT “Time: “, time_up[count], “Tickets available: Closed”
ELSE
PRINT “Time: ”, time_up[count], “Tickets available: ”, tickets_up[count]
END IF NEXT count
PRINT “The train departure times and tickets available for four journeys coming down are:”
FOR count 1 TO 4
IF tickets_down[count] = 0 THEN
PRINT “Time: “, time_down[count], “Tickets available: Closed”
ELSE
PRINT “Time: ”, time_down[count], “Tickets available: ”, tickets_down[count]
END IF NEXT count
END
TASK 2 – Efficiency:
• Use of CONSTANT to hold fixed value of ticket cost.
• Use of WHILE loop to validate all user inputs and output appropriate error messages when validation fails.
• Use of WHILE loop to check that the number of tickets for the required train journeys up and down the mountain is available.
• Use of IF statement to determine indexes of both journeys.
• Use of IF statement to check the number of passengers travelling and then accordingly calculate group discount.
• Use of IF statement to check the number of tickets still available and then accordingly either display them or output ‘Closed’.
• Use of DIV function to calculate the number of tenth passengers.
• Use of FOR loop to output details of journeys for the screen display.
TASK 2 – Explanation of Pseudocode:
TASK 2 – Expected Questions:
1. State two variables you used for Task 2. State the data type and purpose of the variables.
2. Describe the data structures you have used in Task 2. Include the name(s), data type, sample data and usage for each structure.
3. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
You should assume that Task 1 has already been completed.
4. Write an algorithm to complete Task 2 without including any error prompts, using either Pseudocode, programming statements or a flowchart. You should assume that Task 1 has already been completed.
5. Explain how your program completes/performs Task 2. Any programming statements used in your answer must be fully explained.
6. Explain how you calculated the number of every tenth passenger (part of Task 2). You can include Pseudocode or programming statements as part of your explanation.
7. Explain how you calculated the total money taken for each train journey including the group discount. You can include Pseudocode or programming statements as part of your explanation.
8. Explain how you totalled the data for the passengers, money and number of tickets available for each train journey. You can include Pseudocode or programming statements as part of your explanation.
9. Explain how you calculated the total money taken for each train journey including the group discount. You can include Pseudocode or programming statements as part of your explanation.
10. Explain how you validated any two inputs used in Task 2. State one valid and one invalid input to test your validation methods (valid and invalid test data). You can include Pseudocode or programming statements as part of your explanation.
11. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that groups of between thirty and two hundred passengers inclusive get a free ticket for every thirtieth passenger. You should assume that Task 1 has already been completed.
12. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that none of the passengers get any free tickets. You should assume that Task 1 has already been completed.
13. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that the passengers return on the next train down the mountain only. You should assume that Task 1 has already been completed.
14. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that groups of between ten and eighty passengers inclusive get a discount of 50% only on tickets for every tenth passenger. You should assume that Task 1 has already been completed.
15. Write an algorithm for Task 2, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that the ticket cost is $40 for the journey up and $40 for the journey down. You should assume that Task 1 has already been completed.
16. Comment on the efficiency of your code for Task 2.
TASK 3 – Pseudocode:
BEGIN
DECLARE total_passengers_up 0, total_passengers_down 0, total_passengers 0 AS INTEGER DECLARE total_money_up 0.0, total_money_down 0.0, total_money 0.0 AS FLOAT
DECLARE most_passengers 0, most_passengers_train_time 0 AS INTEGER DECLARE count 0 AS INTEGER
DECLARE train_direction “” AS STRING
PRINT “The number of passengers that travelled on 4 journeys up and the total money taken for each journey up is:”
FOR count 1 TO 4
PRINT “Time: ”, time_up[count], “Passengers travelled: ”, passengers_up[count], “Money taken: $“, money_up[count]
NEXT count
PRINT “The number of passengers that travelled on 4 journeys down and the total money taken for each journey down is:”
FOR count 1 TO 4
PRINT “Time: ”, time_down[count], “Passengers travelled: ”, passengers_down[count], “Money taken: $“, money_down[count]
NEXT count
FOR count 1 TO 4
total_passengers_up passengers_up[count] + total_passengers_up
total_passengers_down passengers_down[count] + total_passengers_down total_money_up money_up[count] + total_money_up
total_money_down money_down[count] + total_money_down NEXT count
total_passengers total_passengers_up + total_passengers_down total_money total_money_up + total_money_down
PRINT “The total number of passengers that travelled today were: “, total_passengers PRINT “The total money taken for today is: $“, total_money
FOR count 1 TO 4
IF passengers_up[count] > most_passengers THEN most_passengers passengers_up[count]
most_passengers_train_time time_up[count]
train_direction “up”
END IF
IF passengers_down[count] > most_passengers THEN most_passengers passengers_down[count]
most_passengers_train_time time_down[count]
train_direction “down”
END IF NEXT count
PRINT “The train with most passengers travelled ”, train_direction, “at time:“, most_passengers_train_time
END
TASK 3 – Efficiency:
• Use of FOR loop to output number of passengers and total money taken for each journey up and down separately.
• Use of concept of TOTALLING to calculate the total passengers and total money taken for all journeys combined.
• Use of IF statement to determine/check the train carrying most number of
passengers and then accordingly displaying the train timing and direction.
TASK 3 – Explanation of Pseudocode:
TASK 3 – Expected Questions:
1. State two variables you used for Task 3. State the data type and purpose of the variables.
2. Describe the data structures you have used in Task 3. Include the name(s), data type, sample data and usage for each structure.
3. Write an algorithm for Task 3, using either Pseudocode, programming statements or a flowchart.
You should assume that Task 1 and Task 2 have already been completed.
4. Write an algorithm to complete Task 3 without including any output messages, using either Pseudocode, programming statements or a flowchart. You should assume that Task 1 and Task 2 have already been completed.
5. Explain how your program completes/performs Task 3. Any programming statements used in your answer must be fully explained.
6. Explain how you calculated the total passengers and total money taken for the day (part of Task 3).
You can include Pseudocode or programming statements as part of your explanation.
7. Explain how you found the train journey with most passengers that day. You can include Pseudocode or programming statements as part of your explanation.
8. Write an algorithm for Task 3, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to find and display the train journey with the least passengers that day. You should assume that Task 1 and Task 2 have already been completed.
9. Write an algorithm for Task 3, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to find and display the train journey with the most passengers as well as least passengers that day. You should assume that Task 1 and Task 2 have already been completed.
10. Comment on the efficiency of your code for Task 3.