0% found this document useful (0 votes)
88 views12 pages

Task 1 Complete-1

The document provides details about Task 1, which involves setting up a screen display for a train reservation system. Key points: 1) Task 1 requires initializing data structures to total passengers and money for each of the 8 daily train journeys (4 up, 4 down). Arrays will store timings, tickets, and totals separately for each journey. 2) Train timing and ticket info for the 4 up and 4 down journeys will be stored in separate arrays. Each train has 6 coaches with 80 seats, except the last down train which has 2 extra coaches. 3) A screen display will be set up using FOR loops to output the timing and ticket arrays, presenting info for up and down jour

Uploaded by

Shaheer Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views12 pages

Task 1 Complete-1

The document provides details about Task 1, which involves setting up a screen display for a train reservation system. Key points: 1) Task 1 requires initializing data structures to total passengers and money for each of the 8 daily train journeys (4 up, 4 down). Arrays will store timings, tickets, and totals separately for each journey. 2) Train timing and ticket info for the 4 up and 4 down journeys will be stored in separate arrays. Each train has 6 coaches with 80 seats, except the last down train which has 2 extra coaches. 3) A screen display will be set up using FOR loops to output the timing and ticket arrays, presenting info for up and down jour

Uploaded by

Shaheer Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Pre-Release May/June 2021

Concept and understanding of TASK 1:

Task 1 – Start of the day.


Write a program to:
• Set up the screen display for the start of the day.
• Initialise 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 totalled separately.
• There are four journeys up and four journeys down every day.

Variables, constants and arrays declarations

Storing the details for train times going up/down and train tickets
available for journey up/down using arrays

Declaring 4 different arrays altogether for totalling and storing money


of all 8 journeys separately (i.e. 4 journeys going up and 4 journeys
coming back down) (i.e. 2 separate arrays for total of journey upwards
and journey downwards and similarly 2 separate arrays for money.

Displaying the timings of trains for journeys going up and down


separately

Displaying the number of train tickets available for journeys going up


and down separately

Page XX
Pre-Release May/June 2021

Explanation of Algorithm of TASK 1:


In this task, we have to set up the screen display along with declaring and initializing suitable data
structures for train times, train tickets, totalling passengers and totalling money.

• Write a program to set up the screen display for the start of the day.

We will make use of 1D arrays to store the information relating to train timings, tickets, passengers and
money for all 8 train journeys.

For setting up the complete screen display, we’ll make use of additional pieces of information given in the
pre-release as well. This includes the following details:

• The train times are displayed on a large screen, together with the number of tickets still available
for each train.

Since we need to display the number of tickets as well, we should also calculate the seats available in each
train:

• Each train has six coaches with eighty seats available in each coach.
• The last train from the top of the mountain has two extra coaches on it.

The train timings and tickets for trains going up will be stored in the table for all 4 journeys like this:

Index time_up tickets_up


1 0900 480 Calculation of tickets
2 1100 480
Each train has six coaches
3 1300 480
with eighty seats available in
4 1500 480 each coach.

1 coach = 80 seats
6 coaches = 80 x 6
6 coaches = 480 seats
Timings for trains Number of tickets
going up available for trains
going up

Page XX
Pre-Release May/June 2021

The train timings and tickets for trains going down will be stored in the table for all 4 journeys like this:

Index time_down tickets_down


Calculation of tickets
1 1000 480
2 1200 480 Each train has six coaches
with eighty seats available in
3 1400 480 each coach.

4 1600 640 1 coach = 80 seats


6 coaches = 80 x 6
6 coaches = 480 seats

Timings for trains Number of tickets


going down The last train from the top of the
available for trains
mountain has two extra coaches
going down
on it.

1 coach = 80 seats
2 coaches = 80 x 2
2 coaches = 160 seats

160 seats + 480 seats


Last train has 640 seats

Page XX
Pre-Release May/June 2021

The screen display involves output of train timings and train tickets available. Therefore it will be
displayed/output using a FOR loop.

Firstly we will output the details for trains going up using a FOR loop like this:

Running of example code:

Index time_up tickets_up


1 0900 480
2 1100 480
3 1300 480
4 1500 480

Index time_up tickets_up


1 0900 480
2 1100 480
3 1300 480
4 1500 480

Page XX
Pre-Release May/June 2021

Secondly we will output the details for trains going down using a FOR loop like this:

Running of example code:

Index time_down tickets_down


1 1000 480
2 1200 480
3 1400 480
4 1600 640

Index time_down tickets_down


1 1000 480
2 1200 480
3 1400 480
4 1600 640

In this way, the timings and tickets of 4 trains going up and 4 trains coming back down will be taken
from their locations in the arrays (after being searched according to index value) and PRINTED/OUTPUT
separately.

Page XX
Pre-Release May/June 2021

To set up the actual display, we will output both the train timings and tickets available in a single line
unlike writing both outputs in separate lines like demonstrated above. Therefore the slight change in the
code would be:

Using the pieces of code given above, the display will be setup. It will look something like the following
example of display:

Screen display:

Welcome to Train Reservation System

The following is a table of the train times and number of train tickets available:
The train departure times and tickets available for four journeys going up are:

Time: 0900 Tickets Available: 480


Time: 1100 Tickets Available: 480
Time: 1300 Tickets Available: 480
Time: 1500 Tickets Available: 480
The train arrival times and tickets available for four journeys coming down are:

Time: 1000 Tickets Available: 480


Time: 1200 Tickets Available: 480
Time: 1400 Tickets Available: 480
Time: 1600 Tickets Available: 640

Page XX
Pre-Release May/June 2021

• initialise suitable data structure(s) to total passengers for each train journey and total the money
taken for each train journey.

We will declare and initialise two arrays for passengers so that the number of every passenger can be
totalled and stored in 2 different arrays. 1 array for the passengers seated in trains going up and another
1 array for the passengers seated in trains going back down.

Similarly, we will declare and initialise two arrays for money earned so that the amount of money can be
totalled and stored in 2 different arrays. 1 array for the money earned from trains going up and another 1
array for the money earned from trains going back down.

• each train journey must be totalled separately.

• there are four journeys up and four journeys down every day.

We will declare following arrays for money: money_up[1:4] and money_down[1:4].

In this manner, the money earned for each train journey going up will be stored in the array money_up in
the respective index value of that train (i.e. 1, 2, 3 or 4).

Similarly the money earned for each train journey going back down will be stored in the array
money_down in the respective index value of that train (i.e. 1, 2, 3 or 4).

As a result, all 8 journeys (4 going up and 4 coming back down) will be totalled and stored separately.

Page XX
Pre-Release May/June 2021

TASK 1 – Pseudocode:
BEGIN
DECLARE count  0 AS INTEGER
DECLARE time_up [1:4], time_down [1:4] AS INTEGER
DECLARE tickets_up [1:4], tickets_down [1:4] AS INTEGER
DECLARE passengers_up [1:4], passengers_down [1:4] AS INTEGER
DECLARE money_up [1:4], money_down [1:4] AS FLOAT

time_up[1]  0900
time_up[2]  1100
time_up[3]  1300
time_up[4]  1500
time_down[1]  1000
time_down[2]  1200
time_down[3]  1400
time_down[4]  1600

tickets_up[1]  480
tickets_up[2]  480
tickets_up[3]  480
tickets_up[4]  480
tickets_down[1]  480
tickets_down[2]  480
tickets_down[3]  480
tickets_down[4]  640

money_up[1]  0.0
money_up[2]  0.0
money_up[3]  0.0
money_up[4]  0.0
money_down[1]  0.0
money_down[2]  0.0
money_down[3]  0.0
money_down[4]  0.0

passengers_up[1]  0
passengers_up[2]  0
passengers_up[3]  0
passengers_up[4]  0
passengers_down[1]  0
passengers_down[2]  0
passengers_down[3]  0
passengers_down[4]  0

Page XX
Pre-Release May/June 2021

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
PRINT “Time: ”, time_up[count], “Tickets available: ”, tickets_up[count]
NEXT count

PRINT “The train departure times and tickets available for four journeys coming down are:”

FOR count  1 TO 4
PRINT “Time: ”, time_down[count], “Tickets available: ”, tickets_down[count]
NEXT count

END

TASK 1 – Efficiency:

• Use of ARRAYS to store train timings and number of train tickets available.
• Use of different ARRAYS to store and total the number of passengers and
money earned separately for each train journey.
• Initialization of all ARRAYS with pre-defined values.
• Use of FOR loops to output details of trains departure and arrival.

Page XX
Pre-Release May/June 2021

TASK 1 – Explanation of Pseudocode:

Page XX
Pre-Release May/June 2021

Page XX
Pre-Release May/June 2021

TASK 1 – Expected Questions:


1. State three arrays you used for Task 1. State the data type and purpose of the arrays.
2. Describe the data structures you have used in Task 1 to store the data for the train. Include the
name(s), data type, sample data and usage for each structure.
3. Write an algorithm for Task 1, using either Pseudocode, programming statements or a flowchart.
4. Write an algorithm for Task 1, using either Pseudocode, programming statements or a flowchart.
Assume that the data structures for storing data about train journeys going up and down have
already been initialized with predefined values.
5. Write an algorithm to complete Task 1 without including any appropriate prompts, using either
Pseudocode, programming statements or a flowchart.
6. Explain how your program completes/performs Task 1. Any programming statements used in your
answer must be fully explained.
7. Explain how you displayed the complete details for all the journeys (part of Task 1)? You can include
Pseudocode or programming statements as part of your explanation.
8. Write an algorithm for Task 1, using either Pseudocode, programming statements or a flowchart.
Change the algorithm to ensure that the money earned and passengers for each journey are
displayed too.
9. Comment on the efficiency of your code for Task 1.

Page XX

You might also like