Question: #include #include #include #define MAX_FLIGHTCODE_LEN 6 #define MAX_CITYCODE_LEN 3 #define MAX_NUM_FLIGHTS 5 #define DB_NAME database void print_menu (void) { printf( 1. add a flight
#include
#define MAX_FLIGHTCODE_LEN 6 #define MAX_CITYCODE_LEN 3 #define MAX_NUM_FLIGHTS 5 #define DB_NAME "database"
void print_menu (void) { printf(" " "1. add a flight " "2. display all flights to a destination " "3. save the flights to the database file " "4. load the flights from the database file " "5. exit the program " "Enter choice (number between 1-6)> "); } /* 1. add a flight Add a new flight to the flights through the terminal. You should collect the input by asking multiple questions from the user.
Enter flight code> Enter departure info for the flight leaving SYD. Enter month, date, hour and minute separated by spaces> Enter arrival city code> Enter arrival info. Enter month, date, hour and minute separated by spaces>
Your program should be able to check the format of the flightcode. The first two characters of the flightcode should be uppercase letters (A-Z) representing the airline. The rest of the flightcode should be numerals (0-9) representing the flight number. The program should works even if the flight code contains 2 letter and 1 number like (VA1) There must be 1-4 numerals as the flight number part of the flightcode. No spaces in the flightcode.
2. display all flights to a destination Prompt the following question
Enter arrival city code or enter * to show all destinations>
The user may enter the abbreviation of MAX_CITYCODE_LEN characters for the arrival city. The program should display all flights to the requested destination. If the user input is *, display all flights.
The display format should is as follows.
Flight Origin Destination ------ --------------- --------------- VA1 SYD 11-26 09:54 LAX 11-26 18:26
Pay attention to the strict formatting guide:
Flight - left aligned, MAX_FLIGHTCODE_LEN (i.e. 6) chars at most. Origin and Destination City - left aligned, MAX_CITYCODE_LEN (i.e. 3) chars at most. Month, day, hour, minute - two digits with leading zeros 3. save the flights to the database file Save the flights in the hard disk as a binary/text file named database. You may use your own format to save the data. You should overwrite if database file already exists. It is up to you to create your own data storage format for the database file. Your program should be able to read the database that was created by itself. You can create the database as a text or binary file. You do NOT need to be able to create a database identical to the database of the sample executable. You do NOT need to be able to read the database of the sample executable. 4. load the flights from the database file Read the database file and put the data into flights. You may only read the data files created by your own program. You should overwrite the flights array you had in memory when loading from the file.
5. exit the program Exit the interactive program.
Enter choice (number between 1-5)> -1 Invalid choice
/*
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
