Assignment declaration: File management, data structures. Write a program that helps SJ-trains with seat booking in a railway carriage. On the screen a picture similar to the one below should appear....


Assignment declaration: File management, data structures.




Write a program that helps SJ-trains with seat booking in a railway carriage. On the screen a picture similar to the one below should appear. The seat numbering should be done as it appears on the picture below (Tips: Modulo can be helpful for arranging columns and rows).




When the program is started, the user must specify which carriage to book. (There are two carriages (Quiet section and Normal section) and the system can only make bookings in one carriage at a time.). Already booked seat numbers should be displayed on the screen accordingly, for example by exchanging the seat number with two asterisk '**'





















1 8 9 16


2 7 10 15




17 24 25 32


18 23 26 31



Quiet section



Normal section




3 6 11 14


4 5 12 13




19 22 27 30


20 21 28 29





With the help of the following menu, the user should be able to book or cancel seats as well as print tickets of their latest bookings (i.e those that have not already been printed).




What do you wish to do?




• Book, write ‘B’, on the same line followed by the desired number of tickets.


• Cancel, write ‘A’, on the same line followed by a seat number.


• To print the most recently booked tickets, write ‘S’.


• Exit, type ‘Q’


Your choice:




After each booking / cancellation, the picture for the carriages should be updated on the screen to show it’s new status. For example if seats number 1, 5, 6 and 30 have been booked the picture should appear like this:





















** 8 9 16


2 7 10 15




17 24 25 32


18 23 26 31



Quiet section



Normal section




3 ** 11 14


4 ** 12 13




19 22 27 **


20 21 28 29





This program only needs to print tickets for a single route, e.g. between Stockholm and Gothenburg. The seat tickets are printed on a separate "ticket file" with the following


appearance:




SEAT RESERVATION


Sth-Gbg 9:05


Seat 30


Quiet section


Aisle seat




Extra requirements: Error message must be printed out in case of incorrect entries, eg:






  • Booking more places then what is left.




  • Cancellation of an unbooked seat.




  • Cancellation of seat number outside the interval 1. . . 32




  • “Print” is selected, even though no bookings have been made.




  • Make sure that booked seats end up next to each other. Otherwise, the program should ask if the customer is okay with separate seats.



Jan 05, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here