Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DESCRIPTION( IN C ) (code must be in c) Thanksgiving Break is fast approaching, so, we hereby present Mizzous state-of-the-art online ticket booking system, Mizzou

DESCRIPTION( IN C )

(code must be in c) Thanksgiving Break is fast approaching, so, we hereby present Mizzous state-of-the-art online ticket booking system, Mizzou Airline Reservation System. Which will be developed by you. This application helps in reserving flight seats. This is done via implementing the 8 user-defined functions as explained below. Your program must print a menu for the user to select what he needs to do with the application. There will be admin mode which requires log-in via a passcode. There will be an option for reserving a seat on a flight. Third option is to exit the application. GLOBAL CONSTANTS and VARIABLES: #define ROW 12 #define COL 6 #define MAX 25 int costMatrix[ROW][COL]= { {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500}, {500,200,500,500,200,500} }; Functions to implement: 1. void initialSeats(char flight[][COL], int count); The initialSeats function takes in a two-dimensional char array created in main. It will initialize all array elements to the character O. O symbolizes the seat on the plane is open and can be taken. The int count parameter is used to symbolize the number of people who already have a seat on the plane; this is a random number sent from main (use rand() to send this number). In this function it will randomly create and assign an index in the two-dimensional array with the character X for each person up to value of count. X is used to symbolize that an element in the two-dimensional array is occupied. This will be used later on in the program. MAKE SURE TO SEED RAND in MAIN. Below is the way to randomly generate the seats for each passenger to take. This function should be called as soon as your program starts. Keep in mind the possibility of the randomized index overwriting X, if it was already there. You have to handle that case. Beware!! int row = rand() % ROW; int col = rand() % COL; 2. void displayMenu(); Prints the display options. Admin mode, Reserve a seat and Exit. This is the main menu. 3. void printFlightMap(char flight[][COL]); The printFlightMap function is printing off a two-dimensional character array. Thus, printing off the characters stored in each index of the two-dimensional array either O or X. As noted above the ROW and COL are #defined in your program, use them. For loops are your friends here. Called in admin mode and during reserving a seat (specifically in seatReservation). 4. int loginMatch(int passcode,int adminPasscode); The loginMatch function is called to compare a pair of integers, the function returns 1 if both numbers match and 0 if there is no match. This is called with the number the user entered and the admin password. This is called in admin mode. 5. int getTotalRevenue(char f1[][COL], char f2[][COL], char f3[ ][COL]); Note: f1, f2, f3 are flight1, flight2, flight3, just shorthanded. The getTotalRevenue function will take in all three two-dimensional character arrays created in main and calculate the total revenue using the costMatrix two-dimensional array. With each two-dimensional array f1, f2, and f3, search for the character X stored in them, upon finding the index of the character X, use the index to reference inside of the global two-dimensional array costMatrix (look above in Constants and Global Variables). While inside of costMatrix array, add the value stored in the two-dimensional array with a running total variable (Hint use +=). The function will return the total revenue earned thus far from seats reserved in all 3 flights. So, you will need nested for-loops. This is called only in admin mode. 6. void flightMenu(); Prints the three flight options as shown. Flights to Miami, Nashville and Las Vegas. This is done when reserve a seat option is chosen. 7. void seatReservation(char flight[][COL]); The seatReservation function takes in a two-dimensional array and allows the user to reserve an index on the two-dimensional array. Before any reserving is done, this function calls the printFlightMap function mentioned earlier to allow the user to see the already populated two-dimensional array for that flight. Then, the user is asked to enter a row and column to reserve a seat. Additionally, this function will have built in error checking (look below at output example) Once the user has inputted a correct index within [0, ROW) and [0, COL) in the two-dimensional array, this function needs to check if that index entered is already taken in the two-dimensional array with the character X. If the index is populated with X, an error will be shown to the user (look at the output below) and have them re-enter a new possible row and column again. If the index entered is not filled with X, then assign that index with X, i.e. changing the element from O to X. Before the function ends, it will call the function printFlightMap again and prints a success message. Remember rows run from 0-5 and columns from 0-3. Error check for this too. 8. void printMessage(char name[],char num[]); //DO THIS, IS IF YOU ARE DOING THE BONUS This function is called for each flight option after the seatReservation() is called. It takes in two strings, name of passenger and the flight number for that particular case. Both are character arrays (strings). For flight Cou->Miami number must be set as MIA1050, for Cou->Nashville number must be set as BNA1050, for flight Cou->Las Vegas num must be set as LAS1050, this must be done in main and the name and particular number must be sent to this function. Once in this function, you will merge (important part) the two strings into third string and print that as the e-Ticket as shown below and print a confirmation message. Eg1: name is Fred number is MIA1050, your merged string should be FMrIeAd1050. Print this as the booking confirmation number. Eg2: name is Ries number is LAS1050, you merged string should be RLiAeSsl050. Eg3: name is Christopher number is BNA1050, your merged string should be CBhNrAi1s0t5o0pher 9. int main(void) The main function will be doing all (most of) the function calls. In main, you will need to create four character arrays of flight_1[ROW][COL], flight_2[ROW][COL], flight_3[ROW][COL], and strings name[MAX],flight_number[MAX] adminPasscode= 105018; // everyone must keep this the same Also, before you call initialSeats function on all the flights arrays individually, make sure to find how many people already reserved seats. This is done by creating a local variable seats = rand % 20 + 1 (this is your int counts in initialSeats function), rand()%20 +1 will give a random number between 1-20; you only need to do this once. A menu system will be displayed for the users to run specific parts of the program (See output below of what the menu system needs to look like). Make sure to implement error checking for invalid input! On the main menu, the user will see a display of options: The options are 1: Admin Portal, 2: Reserve a seat on a flight, and 3: Quit. The menu will need to loop until the exit option is chosen. To access the Admin Portal, the user enters a 1, and then must type a passcode that will be stored in a variable. Now, verify the passcode, call the loginMatch function (you should compare) with passcode and adminPasscode to verify if it is an authentic log-in attempt. If the pair match, that is, they are equivalent then it means successful log-in. Upon successful verification, inside of the admin portal, call printFlightMap on each flight array and getTotalRevenue (See output below). Declare these variables in main(). To access Reserve a seat, the user enters a 2. Inside of this portal, the user is displayed the three flights that can be accessed to book a seat. (See below output). As always verify the user input for flight option (1-5). 2 character arrays will be used, name and flight_number. Once a valid flight option is chosen. Ask for the users first name and store it in name[] and store the flight numbers (MIA1050,BNA1050,LAS1050) in flight_number[] as specified above for that flight. Then, send the corresponding flight array to seatReservation, after successful reservation the user will be relocated back to the main menu. (If you are doing the bonus) then call the printMessage with name[] and that particular flight_number[],. Note: flight1 is Miami, flight2 is Nashville, flight3 is Las Vegas. Please go through Sample Output and the document clearly before starting out. Sample Output Your output will vary but the outline must look similar. jer676@tc-m610-login-node623:/home/jer676/CS1050/FS2018/hw/hw2>compile k-hw2.c jer676@tc-m610-login-node623:/home/jer676/CS1050/FS2018/hw/hw2>./a.out ********* WELCOME TO MIZZOU AIRLINE BOOKING SYSTEM ********* 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 4 Wrong option! Choose a right option 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 0 Wrong option! Choose a right option 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 3 Terminating the Program Thank you for using Mizzou Airline Booking System

jer676@tc-m610-login-node623:/home/jer676/CS1050/FS2018/hw/hw2>./a.out ********* WELCOME TO MIZZOU AIRLINE BOOKING SYSTEM ********* 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 123 Wrong option! Choose a right option 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 105016 Wrong option! Choose a right option 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 105018 Wrong option! Choose a right option 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 1 Enter the login passcode to log in as admin: 123 Invalid Passcode combination Enter the login passcode to log in as admin: 105016 Invalid Passcode combination Enter the login passcode to log in as admin: 105018 Printing the Flight Map of flight Columbia to Miami.... O O O O O O O O O O O O O X O O O O O O O X X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O X O O O O O O O O O O O O O O O O O O O Printing the Flight Map of flight Columbia to Nashville.... O O O O O O O O O O O O O O O O O O O O O O O X O O O O O O X O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O X X O O O X O O O O Printing the Flight Map of flight Columbia to Las Vegas.... O O O O O O O O X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O O O O O O X O O O O O O O O O O O X O O O O O O O O O O O O O O O X The total earning from all the flights: $5700 You are logged out now! 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 2 1.) COU ----> MIA 2.) COU ----> BNA 3.) COU ----> LAS Choose a flight: 4 1.) COU ----> MIA 2.) COU ----> BNA 3.) COU ----> LAS Choose a flight: 0 1.) COU ----> MIA 2.) COU ----> BNA 3.) COU ----> LAS Choose a flight: 1 Enter your first name: James O O O O O O O O O O O O O X O O O O O O O X X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O X O O O O O O O O O O O O O O O O O O O Which Seat row do you want?: 0 Which seat column do you want?: 0 Your requested seat has been reserved X O O O O O O O O O O O O X O O O O O O O X X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O X O O O O O O O O O O O O O O O O O O O Congrats James !!, you flight MIA1050 is booked, enjoy your trip Your e-ticket number is : JMaImAe1s050 Enjoy your Thanksgiving Break :) 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 2 1.) COU ----> MIA 2.) COU ----> BNA 3.) COU ----> LAS Choose a flight: 2 Enter your first name: abcdefghijklmnopqrstuvwxyz O O O O O O O O O O O O O O O O O O O O O O O X O O O O O O X O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O X X O O O X O O O O Which Seat row do you want?: 3 Which seat column do you want?: 24 Seat columns are between 0 to 5. Try Again.Which seat column do you want?: 3 Your requested seat has been reserved O O O O O O O O O O O O O O O O O O O O O X O X O O O O O O X O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O X X O O O X O O O O Congrats abcdefghijklmnopqrstuvwx !!, you flight BNA1050 is booked, enjoy your trip Your e-ticket number is : aBbNcAd1e0f5g0hijklmnopq Enjoy your Thanksgiving Break :) 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 2 1.) COU ----> MIA 2.) COU ----> BNA 3.) COU ----> LAS Choose a flight: 1 Enter your first name: Jim X O O O O O O O O O O O O X O O O O O O O X X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O X O O O O O O O O O O O O O O O O O O O Which Seat row do you want?: 0 Which seat column do you want?: 0 Sorry!! someone has reserved that seat. Please Try Again. Which Seat row do you want?: 2 Which seat column do you want?: 1 Sorry!! someone has reserved that seat. Please Try Again. Which Seat row do you want?: 2 Which seat column do you want?: 0 Your requested seat has been reserved X O O O O O O O O O O O X X O O O O O O O X X O O O O O O O O O O O O O O O O O O O O O X O O O O O O O X O O O O O O O O O O O O O O O O O O O Congrats Jim !!, you flight MIA1050 is booked, enjoy your trip Your e-ticket number is : JMiImA1050 Enjoy your Thanksgiving Break :) 1.) Admin Log-in 2.) Reserve a seat 3.) Exit Choose an option: 3 Terminating the Program Thank you for using Mizzou Airline Booking System. jer676@tc-m610-login-node623:/home/jer676/CS1050/FS2018/hw/hw2>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

The Functions of Language Problems with Language

Answered: 1 week ago

Question

The Nature of Language

Answered: 1 week ago