Question: #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

#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 and struct student only. Each * struct definition should have only the fields mentioned in the assignment * description. *******************************************************************************/

struct date_time { int month; int day; int hour; int minute; }; typedef struct date_time date_time_t;

struct flight { char flightcode[MAX_FLIGHTCODE_LEN+1]; date_time_t departure_dt; char arrival_city [MAX_CITYCODE_LEN+1]; date_time_t arrival_t; }; typedef struct flight flight_t;

flight_t makeflight(int monthd, int dayd, int hourd, int minuted,int montha, int daya, int houra, int minutea,char flightcode[MAX_FLIGHTCODE_LEN+1],char arrival_city [MAX_CITYCODE_LEN+1]);

int main() { int choice; int monthd; int dayd; int hourd; int minuted; int montha; int daya; int houra; int minutea; char flightcode[MAX_FLIGHTCODE_LEN+1]; char arrival_city [MAX_CITYCODE_LEN+1]; flight_t flights [MAX_NUM_FLIGHTS]; do { printf("1. add a flight "); printf("2. display all flights to a destination "); printf("3. save the flights to the database file "); printf("4. load the flights from the database file "); printf("5. exit the program "); printf("Enter choice (number between 1-5)> "); scanf("%d",&choice);

switch (choice) { case (1): printf("Enter the flight code: "); scanf("%s",&flightcode); printf("Enter departure info for the flight leaving SYD. "); do{ printf("Enter month, date, hour and minute separated by spaces> "); scanf("%d %d %d %d",&monthd,&dayd,&hourd,&minuted); if (12 "); scanf("%s", &arrival_city); printf("Enter arrival info. "); do{ printf("Enter month, date, hour and minute separated by spaces> "); scanf("%d %d %d %d",&montha,&daya,&houra,&minutea); if (12

} while (choice != 5); return 0; }

flight_t makeflight(int monthd, int dayd, int hourd, int minuted,int montha, int daya, int houra, int minutea,char flightcode[MAX_FLIGHTCODE_LEN+1],char arrival_city [MAX_CITYCODE_LEN+1]) { flight_t f; f.flightcode[MAX_FLIGHTCODE_LEN+1]=flightcode[MAX_FLIGHTCODE_LEN+1]; f.departure_dt.month=monthd; f.departure_dt.day=dayd; f.departure_dt.hour=hourd; f.departure_dt.minute=minuted; f.arrival_city [MAX_CITYCODE_LEN+1]=arrival_city [MAX_CITYCODE_LEN+1]; f.arrival_t.month=montha; f.arrival_t.day=daya; f.arrival_t.hour=houra; f.arrival_t.minute=minutea;

return f; }

i am trying to achieve the following :

Description

Data Engineers regularly collect, process and store data. In this task you will develop a deeper understanding of how C programming language can be used for collecting, processing and storing data. In this assignment you get the opportunity to build an interactive program that can manage the list of flights departing Sydney Airport.

The list is stored as an array of flight_t type structures

flight_t flights [MAX_NUM_FLIGHTS];

The flight_t is a structure typedef for struct flight. The struct flight contains the following fields

flightcode - array of MAX_FLIGHTCODE_LEN+1 chars (string)

departure_dt - a structure of date_time_t type as defined below

arrival_city - array of MAX_CITYCODE_LEN+1 chars (string)

arrival_dt - a structure of date_time_t type as defined below

Note that we now have a struct nested within a struct. The date_time_t is a structure typedef for struct date_time. The struct date_time contains the following fields,

month - integer between 1 and 12 (inclusive)

day - integer between 1 and 31 (inclusive)

hour - integer between 0 and 23 (inclusive)

minute - integer between 0 and 59 (inclusive)

Your program interacts with the nested struct array in your memory (RAM) and simple database file in your hard disk. It should provide the following features:

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>

so basically i need to know how can i edit my program to store the user entered flight info in the flights array. i Know how to store just one, but i need to be able to do it consecutively, meaning that once the first flight is stored, i need the program to jump back to the menu and prest the user with the option add another flight to the flights array. The flights array is an array of structures. Any help would be appreciated.

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!