Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. Description
  2. 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.
  3.  
  4. The list is stored as an array of flight_t type structures
  5.  
  6. flight_t flights [MAX_NUM_FLIGHTS];
  7.  
  8. The flight_t is a structure typedef for struct flight. The struct flight contains the following fields
  9.  
  10. flightcode - array of MAX_FLIGHTCODE_LEN+1 chars (string)
  11. departure_dt - a structure of date_time_t type as defined below
  12. arrival_city - array of MAX_CITYCODE_LEN+1 chars (string)
  13. arrival_dt - a structure of date_time_t type as defined below
  14. 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,
  15.  
  16. month - integer between 1 and 12 (inclusive)
  17. day - integer between 1 and 31 (inclusive)
  18. hour - integer between 0 and 23 (inclusive)
  19. minute - integer between 0 and 59 (inclusive)
  20. 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:
  21.  
  22. 1. add a flight
  23. Add a new flight to the flights through the terminal. You should collect the input by asking multiple questions from the user.
  24.  
  25. Enter flight code>
  26. Enter departure info for the flight leaving SYD.
  27. Enter month, date, hour and minute separated by spaces>
  28. Enter arrival city code>
  29. Enter arrival info.
  30. Enter month, date, hour and minute separated by spaces>
  31.  
  32. 2. display all flights to a destination
  33. Prompt the following question
  34.  
  35. Enter arrival city code or enter * to show all destinations>
  36.  
  37. 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.
  38.  
  39. The display format should is as follows.
  40.  
  41. Flight Origin Destination
  42. ------ --------------- ---------------
  43. VA1 SYD 11-26 09:54 LAX 11-26 18:26
  44.  
  45. Pay attention to the strict formatting guide:
  46.  
  47. Flight - left aligned, MAX_FLIGHTCODE_LEN (i.e. 6) chars at most.
  48. Origin and Destination
  49. City - left aligned, MAX_CITYCODE_LEN (i.e. 3) chars at most.
  50. Month, day, hour, minute - two digits with leading zeros
  51. 3. save the flights to the database file
  52. 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.
  53.  
  54. 4. load the flights from the database file
  55. 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.
  56.  
  57. 5. exit the program
  58. Exit the interactive program.
  59.  
  60. Careless Users
  61. 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.
  62.  
  63. Enter choice (number between 1-5)>
  64. -1
  65. Invalid choice
  66.  
  67. Or a careless user may try to add 365 as the month (month should be between 1 and 12). Or try to add a flight to the flights array when it already contains MAX_NUM_FLIGHTS flights, etc.
  68.  
  69. Run the sample executable to futher understand the expected behaviour.
  70.  
  71. Check the formatting of the flightcode
  72. WARNING: Attempting this feature is recommended only for advanced students who enjoy a small challenge. You may need to do your own research, but more than that you may have to be creative. By using incorrect techniques you could very well introduce more bugs in your code and it could be time consuming. The special techniques required for this purpose will not be assessed in the final exam.
  73.  
  74. 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. There must be 1-4 numerals as the flight number part of the flightcode. No spaces in the flightcode.
  75.  
  76. Run the sample executable to further understand the expected behaviour.
  77.  
  78. The database file
  79. 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.
  80.  
  81. 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement