Write a program to book train tickets as per the details given below.
- Train starts from station 'A' and reaches station 'E'.
- Assume the station order as A -> B →> C -> D →> E
- Tickets can be booked from any place, i.e ('A' to 'E) or (C' to 'E) or (B' to 'D') etc...
- A single ticket can be booked for multiple passengers. For example, if four people are travelling as a group, then it will be one ticket which will have the seating information for four people.
- The train has only one coach with eight seats.
- There can be a maximum of 2 Waiting list seats in addition to 8 confirmed seats.
- Each icket ia uniquety idented ty a sequentially generated number called INR (both for contimed and waiting liat booking )
- It a passenger la allocated a seat for a ticket booked between D -→ E, then same neat should not be allotted for other tickete becked for A-sE, where as it can be allocated for any booking between stations A -> D
- Book Hokets only when all the requested number of seats are avallable in a booking (either Confirmed or WL deat). For e. If 4 seats are requested, book only when all four are available but should not book when only 3 or less seats are available.
- Each toket once booked / cancelled should have the source, destination, no. of seats, and the status (booked / cancelled) printed.
- A tieket should be cancelled using the PNR. Once a ticket has been cancelled, the PNR should not be reused again.
- Partial cancellation should be supported, le if a PNR has 4 seats booked, then it should be possible to cancel 2 seats alone.
- When a ticket la cancelled, the passengere in the waiting list should be moved up provided fellewing conditions are met Assume WL1 is from A -> D and WL2 is from D -> E. If a cancellation happens from C -> E, in such case, the WL.1 cannot be accommodated since it is from A -> D. So, here the WL2 should be moved to confirmed list
- You can hard code the input in the below format in your program.
- Booking format (‹book> ‹Source station> «Destination station> ‹No of tickets>)
- book,C,D,2
- cancel,2,2
- Cancel format ( «PNR Number> «Number of tickets>)
- To print the booking summary & chart chart
Comments (1)


