Advanced level 2024 HIHS mock computer science 3

Advanced level 2024 HIHS mock computer science 3

Advanced level 2024 HIHS mock computer science 3

PROGRAMMING: ELECTRIC MOUNTAIN RAILWAY SYSTEM
An electric mountain railway makes four return trips every day. In each trip the train goes up the mountain and back down. The train
leaves from the foot of the mountain at 09:00, 11:00, 13:00 and 15:00. The train returns from the top of the mountain at 10:00, 12:00,
14:00 and 16:00. Each train has SIX coaches with EIGHTY seats available in each coach. Passengers can only purchase a return ticket;
all tickets must be purchased on the day of travel. The cost is $25 for the journey up and $25 for the journey down. Groups of
between ten and eighty passengers inclusive get a free ticket for every tenth passenger, provided they all travel together (every tenth
passenger travels free). Passengers must book their return train journey, as well as the departure train journey, when they purchase their
ticket. Passengers can return on the next train down the mountain or a later train. The last train from the top of the mountain has two
extra coaches on it.
The train times are displayed on a large screen, together with the number of tickets still available for each train. Every time a ticket is
booked the display is updated. When a train is full, the word ‘Closed’ is displayed instead of the number of tickets available.
The train times are displayed on a large screen, together with the number of tickets still available for each train. Every time a ticket is
booked the display is updated. When a train is full, the word ‘Closed’ is displayed and ‘Opened’ displayed otherwise.
Task 1 – Start of the day.
At the beginning of the day, you are to set up the screen display for the start of the day for all the Eight journeys. You are to use suitable data
structure(s) to total passengers for each train journey and total the money taken for each train journey. Each train journey must be totaled
separately. There are four journeys up and four journeys down every day.
All variables, constants and other identifiers must have meaningful names. They must be declared globally. A sample code has been
given to you by the supervisor which has contains all the variables which you may need for the smooth running of the programs. You
may add or modify it to fit your needs.
(a) Write a program that displays the available tickets for the day. The pseudo code Procedure Display ( ) for the screen to display
the available tickets is found in the appendix (Page 5).
Save the source code as Task 1 (4 marks)
(b) Run your program and do a screenshot. Save the screenshot as Task 1a (1 mark)
Task 2 – Purchasing tickets.
Tickets can be purchased for a single passenger or a group. When making a purchase, check that the number of tickets for the required
train journeys up and down the mountain is available. If the tickets are available, calculate the total price including any group discount.
Update the screen display and the data for the totals.
(a) State and explain A validation checks that could be used when inputting the number of tickets to buy for Task 2. For each
validation check give one example of normal data and one example of erroneous data.
Validation check ……………………………………………………………………………………….
Normal data ……………………………………………………………………………………………………………………
Erroneous data ………………………………………………………………………………………………………………..
(2 marks)
(b) Write a procedure BuyTickets ( ) in a programming language that inputs the tickets required, calculates the total price for the
ticket(s) purchased by a passenger including a group discount (if applicable) and updates the data structures used for the totals.
Use the pseudocode found in the appendix to write the program. (3 marks)
(c) Apply the Validation checks mentioned in (a) above. Refer to the template file Sample.c (4 marks)
(d) Save your program as Task 2 (1 mark)
(e) Run the program. Screenshot the output and Save it as Task 2a. (2 marks)
Task 3 – End of the day.
(a) Write a Procedure EndofDay ( ) which will display the number of passengers that travelled on each train journey, the total
money taken for each train journey, calculate and display the total number of passengers, the total amount of money taken for the
day; find and display the train journey with the most passengers that day.
(6 marks)
(a) Save your source code as Task 3.c and Print it (1 mark)
(b) Run the Program, screenshot the output and Save as Task 3a. (2 marks)

PDF is loading please wait...

click here to download the candidate folder

Leave a comment

Your email address will not be published. Required fields are marked *

Download our application
kawlo
sponsors Ads