Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A sample program execution is provided at the end of the document, to help you visualize and understand what the program should do. You
A sample program execution is provided at the end of the document, to help you visualize and understand what the program should do. You should use the same input as the sample program, for the screenshots that you submit with your assignment. The flight route is from Johannesburg to Cape Town with the travel duration fixed at 2 % hours. Departure and arrival locations remain the same. o Departure is always from Johannesburg and destination is aiways Cape Town. The departure and arrival times are: Option Departure Time Arrival Time 7:00 9:30 2 9:00 11:30 3 11:00 13:30 4 13:00 15:30 5 15:00 17:30 The seating arrangement is six seats in a row, three on the left side and three on the right side of the plane with a walkway (passage) in between. See the image of the setup below. (image source: http://travelgurureviews.com/kulula-com-reviews/airline-reviews/) o The total number of seats in the flight is 50. You are required to write a program that simulates a flight booking system. COS1511/103/1/2020 There are two classes of travel: First Class and Economy class. The front four rows are considered as 'First Class' and all other rows to the back are 'Economy Class'. o The cost for economy class is fixed at R1 600.00. The first class travel ticket is 20% more costly than the economy class. Questions You are required to do the following. (See the sample output screenshots for clarification). Write a program that will do the following: 1. Prompt (ask) the user to enter his/her full name. Welcome to Cos1511 Flight Booking system Enter full name Hannah George 2. Then display a menu showing the available times for the flight. The user can choose a preferred departure time (option 1 -5). The option selected should be validated for 1-5. Welcome to COs1511 Flight Booking system Enter full name Hannah George The available travel times for flights are: Depart 1. 2. 3. 11.00 Arrive 7.00 9.30 9.00 11.30 Validation for time option 13.30 15.30 17.30 chosen 4. 13.00 5. 15.00 Choose the time by entering the option numbe from the displayed list: Incorrect option! Please choose from 1-5. 3. If the user has entered a valid option, the seating arrangement for that particular flight time should be displayed to the user for the user to choose a seat. The available seats for 7.00 are as follows: First Class(1920.00) |A1|A2|A3|---- |A4|AS| A6| I81|B2|83|--- B4|B5| B6| |ci|c2|c3|- D1 D2 D3|---- D4|D5|D6 Economy class(1600.00) |E1|E2|E3| -- IF1|F2F3|- |G1|G2|G3|- H1|H2|H3|- i11|12| Please key in a seat number to choose a seat(eg:A2) A1 icajcsic6i TE4|ES|E6| F4|FSF6| |G4|G5|G6| If any seats have already been booked for that time, the booked seats should be indicated and displayed using "**". cOS 1511/103/1/2020 The user can then choose a suitable seat number that is available. The seat number should be validated to see if it has already been booked. In other words, if the user enters a seat number that is aiready booked, display a user-friendly message and give the option to enter the seat number again. The available seats for 7.00 are as follows: Flest Class(1920.00) Booked seats indicated with "*** BI[82|83| |c1]c2|c3] |D1|02|03| |Economy class(1600.00) |E1|E2|E3| |F1|F2|F3| IG1|G2|G3| H1|H2|H3| |84|B5|B6| (c4|c5|C6| |04 |D5|D6| |E4|ES|E6| F4|FS|F6| G4|GS|G6| |H4|H5 H6| Seats that are already taken are indicated with an asterisk Please key in a seat number to choose a seat(eg:A2) G3 4. Once the user has successfully chosen an available seat, a Flight booking ticket should be displayed on the screen. Check the sample screenshot for the details that need to be displayed on the ticket. Travel ticket for FLIGHT Name : Hannah George Travel Ticket class : First class : Al : 7,00 : 9.30 Seat No Departure Destination : Johannesburg Cape Town Departure Time Arrival Time ******* . Amount:R1920.00 Thank you for booking with cos1511. Your travel agent for queries is Annie Mathew ******* 5. The program should prompt (ask) the user if they would like to make additional bookings? Then the program should be able to repeat for more than one booking with various flight times. The check for 'y' or 'n' at the "Do you want to continue(Y/N)?" prompt should be case-insensitive. In other words, both Y' and 'y' should be accepted or both 'N' and 'n' should be accepted. Travel ticket for FLIGHT Name Hannah George Departure Destination 1 Johannesburg I Cape Town Travel Tieket class i First class Seat No Departure Time Arrival Time : Al : 7.00 I 0.30 Amount: R1920.00 Thank you for booking with cos1511. Your travel agent for queries is Annie Mathe Do you want to make another book Ing (Y/N)? Melcome to COSTSTI FaE Booking system Enter full name Deon Pieters The available travel tiimes for f1ights are: Depart 1. 7.00 2. 9.00 a. 11.00 4. 13.00 5. 15.00 Choose the time by entering the option number from the displayed list: Arrive 9.30 11. 30 13. 30 15. 30 17. 30 6. When the user has finished all the booking and chosen 'N' or 'n' at the "Do you want to continue(Y/N)?" prompt, the program should display the total number of bookings made for each flight time, just before exiting. mber of bookings made for 7.00 a.m:3 Number of bookings made for 9.00 a.m:0 Number of bookings made for 11.00 a.m:0 Number of bookings made for 13.00 p.m:0 Number of bookings made for 15.00 p.m:1 The program should display the total bookings for each time, before exiting. Process returned e (exe) Press any key to continue. execution time 125.236 s Submit the full program code and output screenshots. Include screenshots in your submission showing: the program repeating; input validations; booking for different flight times. You are required to define and use functions to do the following: Display the menu for flight times, accept the user option and validate the user option. Call the function to validate the menu option from here. Validate the menu option for flight times. Display the seating arrangement (You might have to use two different functions for seat display). o ie. before any booking has been made, you have one seating arrangement with all the seats available. After seats are booked, you have to display the booked seats with "**") Validate the availability of the chosen seat (to check if the seat has been already booked or not). o You DO NOT have to do validation for an invalid entry like 23. We assume that the user enters a valid seat number that is displayed on the screen. You only need to check if it has been already booked or not. Calculate the ticket price.(You are allowed to use a global named constant for the price of economy class, however, wherever you have to display the cost of ticket, you need to use this function to determine the price of the ticket. For instance, when you show the amount in the ticket that is displayed as output for each booking made. Display the ticket, as shown in the sample output, for each booking. The function used to calculate ticket price can be called from this function. DO NOT use global variables. Except that you are only allowed to use global named constants for the following: o Cost of economy class ticket. o An array for storing departure times and arrival times. o For the size of any other arrays you might use. DO NOT use classes to write this program (you should be able to write this program with the help of other data structures that you have learnt). Additional information/ Hints: o You need to store the details of a particular booking, because you have to display the booked seats in the seating arrangement with "**", when the program repeats. O Therefore, you need to think in the direction of storing the details of one booking which are of different data types, in one place. Again, if you are making more than one booking, then you have to store the details of various bookings in an array. Apply what you have learnt and use appropriate data types and data structures. coS1511/103/1/2020 If you want to display the seat number as a combination of letter and number as in A1, A2 etc, then you can use the to_string () function to convert the integer to string and concatenate. For example: char row = 'A'; int col = 1l; string sNo - "; sNo += roW; sNo += to_string (col); Sample Program output (from one execution of the program without exiting): Nelcome to Cos1511 Flight Booking system Enter full name Hannah George The available travel times for flights are: Depart 1. 7.00 2. 9.00 3. 4. 5. 15.00 Choose the time by antering the option number from the displayed list: Arrive 9.30 11.30 11.00 13.30 13.00 15.30 17.30 Incorrect option! Please choose from 1-5. Validation for time option chosen The available seats for 7.00 are as follows: First Class(1920.00) |A1|A2|A3|---- |A4|A5|A6| 81|82|B3| Ic1|c2|C3| D1|02|D3|---- D4 D5 D6| Economy class(1600.00) E1|E2|E3|---- |E4|E5|E6| IF1|F2|F3| |G1|G2|G3| H1|H2|H3|---- |H4|H5 H6| 1|12| Please key in a seat number to choose a seat(eg:A2) A1 B84|B5|B6| |C4|cs|C6| |F4|F5|F6| G4|G5|66| CS1511/103/1/2020 Travel ticket for FLIGHT ******* : Hannah George Travel Ticket class : First class Seat No Departure Time Name : A1 7.00 : 9.30 Departure Destination ****** : Johannesburg : Cape Town Arrival Time ******* Amount:R1928.00 Thank you for booking with COs1511. Your travel agent for queries is Annie Mathew Do you want to make another booking(Y/N)? welcome to Cos1511 Flight Booking system Enter full name Deon Pieters Ticket display for a booking The available travel times for flights are: Depart 1. 7.00 2. 9.00 3. 11.00 13.00 Arrive 9.30 11.30 13.30 15.30 4. 5. 15.00 17.30 Choose the time by entering the option number from the displayed list: The availeble seats for 7.00 are as follows: t Class(1920.00) A2 A3] B1 82 B3| |c1|c2|c3|- |D1|02|03| Econony class(1600.00) |E1 E2|E3|- |E4|ES|E6| F1|F2|F3|- IG1|G2|G3| H1 |H2|H3| 11|12| A4|A5 A6 84 B5 86| |C4|c5|C6| |D4 D5|06| Seats booked should be indicated with |F4|F5|F6| (4|G5|66| Seats that are already taken are indicated with an asterisk Please key in a seat number to choose a seat(eg:A2) G3 Travel ticket for FLIGHT Travel Ticket class : Economy class : G3 : 7.00 : 9.30 Name : Deon Pieters Seat No Departure Destination : Johannesburg : Cape Town Departure Time Arrival Time Amount:R1600.00 Thank you for booking with cos1511. Your travel agent for queries is Annie Mathew ...*** Do you want to make another booking(Y/N)? coS1511/103/1/2020 Welcome to cos1511 Flight Booking system Enter full name bim Baker The available travel times for flights are: Depart 1. 7.00 9.00 Arrive 9.30 2. 3. 4. 5. 15.00 Choose the time by entering the option number from the displayed list: 1 11.30 11.00 13.30 13.00 15.30 17.30 The available seats for 7.00 are as follous: Eirst Class(1920.00) ** A2|A3|---- |A4|A5|A6| |B4|B5|B6| |C4|c5|C6| D1 D2|D3|---- |D4|D5|D6| Economy class(1600.00) E1|E2|E3|---- |E4|E5|E6| |F4|F5|F6| |G4|65|G6| |H4|H5 H6| ter 82 B3|- |c1|c2|c3|- Two seats booked for 7:00 am flight iF1|F2i- H1|H2TH3- Seats that are already taken are indicated with an asterisk Please key in a seat number to choose a seat(eg:A2) A1 was already booked for 7:00 am flight. So display an appropriate message that the seat has already been taken. Sorry, the seat is taken. Please choose a seat that is available D6 * *** ...... Travel ticket for FLIGHT *.... Travel Ticket class : First class Seat No Departure Time Arrival Time Name : Jim Baker Departure Destination Johannesburg : Cape Town : D6 : 7.00 : 9.30 .*.... Amount:R1920.00 Thank you for booking with Cos1511. Your travel agent for queries is Annie Mathew ********* Do you want to make another booking(Y/N)? Welcome to Cos1511 Flight Booking system Enter full name Fiona Bruce The available travel times for flights are: Depart 1. 7.00 2. 9.00 3. 11.00 4. 13.00 5. 15.00 Choose the time by entering the option nueber from the displayed list: Arrive 9.30 11.30 13.30 15.30 17,30 10 coS1511/103/1/2020 The available seats for 15.00 re as follows: First Class(1920.00) IA1|A2|A3|- JA4|AS|A6| i81|82|B3|---- |84|85|86| icijc2|c3|---- (c4lcsic6| [01 02|03|---- 04 05 D6| |Economy class(1600,00) ie1|E2|E3|---- JE4|ES|E6| F1|F2|F3| I61|62|63|---- 64|65|66| H1|H2|H3|--- |11|12| Please key in a seat number 12 A different flight time chosen, and a corresponding display. No bookings were made for this time, so all seats |F4|FS|F6| available. |H4|HS|H6| choose a seat(eg:A2) Travel ticketfor FLIGHT Nane : Fiona Bruce Travel Ticket class : Economy class : 12 : 15.00 : 17.30 Seat No Departure Destination : Johannesburg : Cape Town Departure Timne Arrival Time Amount: R1600.00 Thank you for booking with COs1511. Your travel agent for queries is Annie Mathew ...... Do you want to make another booking(Y/N)? Mimber of bookings made for 7.00 a.m:3 Number of bookings made for 9.00 a.m:0 Number of bookings made for 11.00 a.m:0 Number of bookings made for 13.00 p.m:0 er of bookings made for 15.00 p.m:1 The program should display the total bookings for each time, before exiting. execution time : 125.236 s Process returned e (exe) Press any key to continue. (TOTAL: 100 Marks)
Step by Step Solution
★★★★★
3.38 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
include include include using namespace std string welcome void printseatsstring flight void populateseats bool validateflightstring a bool validateseatstring a int b bool validatebookstring a void pr...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
635d72e6dd304_175713.pdf
180 KBs PDF File
635d72e6dd304_175713.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started