Dr. A.P.J. Abdul Kalam Technical University (AKTU), Lucknow

Lab Exercise

29. Define a structure data type TRAIN_INFO. The type contains Train No.: integer type, Train name: string, Departure Time: aggregate type TIME, Arrival Time: aggregate type TIME, Start station: string, End station: string. The structure type TIME contains two integer members: hour and minute. Maintain a train timetable and implement the following operations:

(i) List all the trains (stored according to train number) that depart from a particular station.
(ii) List all the trains that depart from a particular station at a particular time.
(iii) List all the trains that depart from a particular station within the next one hour of a given time.
(iv) List all the trains between a pair of start station and end station.

Sample Input and Output

Stdin Inputs:

1 14511 Nauchandi Express
Prayagraj
Saharanpur
10 15 23 10 1 14163 Sangam Express
Prayagraj
Meerut
10 31 21 17 1 12687 Dehradun Express
New Delhi
Dehradun
9 10 16 45 3 1 Prayagraj
2 Prayagraj
10 15 3 Prayagraj
10 10 4 New Delhi
Dehradun
6

Sample Result:

         ****TRAIN EDIT MENU****
1. Add Train.
2. Delete Train.
3. Exit Train Edit Menu.
Your Choice: 1

Input Train Number: 14511
Input Train Name: Nauchandi Express
Input Start Station: Prayagraj
Input End Station: Saharanpur
Input Departure Time:
Hour: 10
Minute: 15
Input Arrival Time:
Hour: 23
Minute: 10
Train 14511 added successfully.

         ****TRAIN EDIT MENU****
1. Add Train.
2. Delete Train.
3. Exit Train Edit Menu.
Your Choice: 1

Input Train Number: 14163
Input Train Name: Sangam Express
Input Start Station: Prayagraj
Input End Station: Meerut
Input Departure Time:
Hour: 10
Minute: 31
Input Arrival Time:
Hour: 21
Minute: 17
Train 14163 added successfully.

         ****TRAIN EDIT MENU****
1. Add Train.
2. Delete Train.
3. Exit Train Edit Menu.
Your Choice: 1

Input Train Number: 12687
Input Train Name: Dehradun Express
Input Start Station: New Delhi
Input End Station: Dehradun
Input Departure Time:
Hour: 9
Minute: 10
Input Arrival Time:
Hour: 16
Minute: 45
Train 12687 added successfully.

         ****TRAIN EDIT MENU****
1. Add Train.
2. Delete Train.
3. Exit Train Edit Menu.
Your Choice: 3

         ****MENU****
1. List all the trains departed from a particular station.
2. List all the trains departed from a particular station at a particular time.
3. List all the trains departed from particular station within the next one hour of a given time.
4. List all the trains between a pair of start station and end station.
5. Edit train details.
6. Exit.
Your choice: 1

         ****INPUT DETAILS****
Depart Station: Prayagraj
14163         Sangam Express     Prayagraj     Meerut     10:31     21:17
14511         Nauchandi Express     Prayagraj     Saharanpur     10:15     23:10

         ****MENU****
1. List all the trains departed from a particular station.
2. List all the trains departed from a particular station at a particular time.
3. List all the trains departed from particular station within the next one hour of a given time.
4. List all the trains between a pair of start station and end station.
5. Edit train details.
6. Exit.
Your choice: 2

         ****INPUT DETAILS****
Depart Station: Prayagraj
Train Time:
Hour: 10
Minute: 15
14511         Nauchandi Express     Prayagraj     Saharanpur     10:15     23:10

         ****MENU****
1. List all the trains departed from a particular station.
2. List all the trains departed from a particular station at a particular time.
3. List all the trains departed from particular station within the next one hour of a given time.
4. List all the trains between a pair of start station and end station.
5. Edit train details.
6. Exit.
Your choice: 3

         ****INPUT DETAILS****
Depart Station: Prayagraj
Time:
Hour: 10
Minute: 10
14163         Sangam Express     Prayagraj     Meerut     10:31     21:17
14511         Nauchandi Express     Prayagraj     Saharanpur     10:15     23:10

         ****MENU****
1. List all the trains departed from a particular station.
2. List all the trains departed from a particular station at a particular time.
3. List all the trains departed from particular station within the next one hour of a given time.
4. List all the trains between a pair of start station and end station.
5. Edit train details.
6. Exit.
Your choice: 4

         ****INPUT DETAILS****
Depart Station: New Delhi
Arrival Station: Dehradun
12687         Dehradun Express     New Delhi     Dehradun     9:10     16:45

         ****MENU****
1. List all the trains departed from a particular station.
2. List all the trains departed from a particular station at a particular time.
3. List all the trains departed from particular station within the next one hour of a given time.
4. List all the trains between a pair of start station and end station.
5. Edit train details.
6. Exit.
Your choice: 6

Leave a Reply

Your email address will not be published.

Scroll to Top