Question: /* C Programming * List header files - do NOT use any other header files. Note that stdlib.h is * included in case you want

/* C Programming * List header files - do NOT use any other header files. Note that stdlib.h is * included in case you want to use any of the functions in there. However the * task can be achieved with stdio.h and string.h only. */ #include #include #include

/* * List preprocessing directives - you may define your own. */ #define MAX_FLIGHTCODE_LEN 6 #define MAX_CITYCODE_LEN 3 #define MAX_NUM_FLIGHTS 5 #define DB_NAME "database"

/******************************************************************************* * List structs - you may define struct date_time and struct flight only. Each * struct definition should have only the fields mentioned in the assignment * description. *******************************************************************************/

/******************************************************************************* * Function prototypes - do NOT change the given prototypes. However you may * define your own functions if required. *******************************************************************************/ void print_menu (void);

/******************************************************************************* * Main *******************************************************************************/ int main(void) { /* TODO */ print_menu(); return 0; }

/******************************************************************************* * This function prints the initial menu with all instructions on how to use * this program. * inputs: * - none * outputs: * - none *******************************************************************************/ 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)> "); }

/* Add Flight

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>

It should do all of this:

1-Flight - left aligned, MAX_FLIGHTCODE_LEN (i.e. 6) chars at most.

2-City - left aligned, MAX_CITYCODE_LEN 3 chars at most . For example( VA1 or LAX )

3- Month, day, hour, minute - two digits with leading zeros

Your program should be able to check the format of the flightcode.

The first two characters of the flightcode must be uppercase letters (A-Z)

representing the airline. The rest of the flightcode should be numerals (0-9)

representing the flight number.

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

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. (How to do that I mean how link it on my laptop after implmenting the code)

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.

Careless Users

Your program may assume that the input data type is always the expected type i.e. when the program expects an integer the user must enter an integer. However, a careless user may enter an input that is outside the expected range (but still of the expected data type). Your program is expected to handle careless users. e.g.

Enter choice (number between 1-5)> -1 Invalid choice

*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!