Recent Question/Assignment

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
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 be similar to this, do not copy&paste from this webpage. Please follow the sample executable for the exact display format, including white spaces.
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.
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)
Invalid choice
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.
Run the sample executable to futher understand the expected behaviour.
Check the formatting of the flightcode
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.
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.
Run the sample executable to further understand the expected behaviour.
The database file
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.
Marking Criteria
Criterion Weight
Following good coding practices 50%
Functionality of the program 50%
50% - following good coding practices
Follow the good coding practices listed under LAB01 Task 3. Your code will be manually marked by tutors for the ability to follow this list of good coding practices. The coding style will be checked in the Ed environment under default GEDIT configuration discussed in LAB00 task 2.
To achieve marks for the good coding practices, your submission should not be trivial and you need to attempt to address the task sufficiently. e.g. if the submission is a blank C program that follows all applicable good practices listed in LAB01 Task 4, you will not receive marks for good coding practices.
Rubrics for coding practices:
The sum of above marks will produce 15/30 of the marks for this assignment (15% of the grade in this subject).
50% - functionality of the program
11 Test cases will be used to mark the functionality, the breakdown is 1.35/15 for each test case for test cases 1-10 and 1.5/15 for test case 11 (15% of the grade in this subject).
Functionality of your program will be checked by a series of automated tests done on Ed. The outcome of each test could be:
• PASS - behaviour of your program is identical to the sample executable on Ed
• FAIL - behaviour of your program is different by at least one character
Ed has been configured as follows, until the deadline:
• You will know the PASS/FAIL outcome of each test immediately after submission, allowing you to fix the program before the deadline.
• You have unlimited attempts to see the PASS/FAIL status of each test.
• Ed will NOT show the test inputs, and it will NOT show the diff comparison for you.
• Think about possible test cases yourself and compare your solution with the sample executable.
Ed has been configured as follows, 5 days after the deadline:
• Feedback show the failed test cases.
• No longer accepting submissions
Do NOT hardcode your answers. Tutors will manually check all the submissions. If you hardcode your solution, tutors may change your functionality marks to 0.
NO exceptions to the above criteria will be made under any circumstances.
Compilation Requirement
We will include all compilation flags we have been using throughout the semester. On lab computers your program should compile as follows.
gcc -Wall -Werror -ansi -o syd_flights.out syd_flights.c -lm
We will compile your code on Ed as follows
gcc -Wall -Werror -ansi -o build/syd_flights.out syd_flights.c -lm
Your program must compile with NO errors and NO warnings on Ed. Failing this, Ed will not run any of the functionality tests, hence you will receive 0 marks for the functionality. But we will still mark the coding style.
Libraries Requirement
You are free to use the following C libraries in this assignment:
You do not necessarily have to use all of them. However, you will receive 0 marks for the functionality if you use any libraries other than those listed above.
Your submission will be via Ed. You should submit only one C file named syd_flights.c. Do NOT submit executable files, other file types, and other C files with different names.
You will get 0 marks for the assignment if this requirement is not met.
ALL work you submit must be your own. We take plagiarism very seriously. Why you shouldn't plagiarise?
• This is an individual assignment.
• I will use plagiarism detection software to check that you did not copy parts of the solution from previous submissions, other students in the class, online forums and other online resources.
• If any submission has a high similarity from the plagiarism detection software, the submission will be submitted as a misconduct case to university and the result of this assessment and the subject will be withheld until the misconduct case is resolved.
• Read the specification very carefully.
• Run the sample executable on Ed. You may need to setup file permissions. See LAB01 Task 2.
• Breakdown the task into functions and implement one at a time.
• Do the exit program feature first. Then add flight and display flights features. Do the display all flights feature before working on display selected flights. Then save and read file features.
• Do the complete assignment without considering the format of the flightcode, then think about it.
• Nested structure definition was covered in Forum 05 - Structures and file processing.
• You will need to use a fixed size array with a maximum size to emulate a variable sized array. The source code in Forum 04 - Arrays and strings has everything you need for this.
• Do NOT define the flights array as a global variable.
• The assignment can be done without using pointers. But if you want to use pointers, of course you can.
• All strings in C should be null-terminated i.e. the last character should always be ''. To store MAX_FLIGHTCODE_LEN characters, flightcode array should be MAX_FLIGHTCODE_LEN+1 chars. Same applies to arrival_city.
• Suppose you make a mistake in printing the choices menu. Instead of -5. exit the program-, you print -5 exit my program now-. This message will be printed in each test, hence you will fail all tests and receive 0 marks for the functionality of your program.
• Submit to Ed early! It shows the outcome of each test case (Pass/Fail) immediately.
Some test cases for code (this is not provided in the template to prevent hard coding)
Test 1: Checks if the correct function gets called based on the user input
Test 2, 3, 7: Check add a flight and display flights functionalities
Test 4 - 6: Check database functionalities, display, save, load and pick the choices in different orders
Test 8 - 9: Check invalid user input (eg: date format)
Test 10: Checks invalid user input (eg: exceeding the maximum number of flights)
Test 11: Check invalid user input (eg: flight code format, extra-long input)
NOTE***Add COMMENTS THROUGHOUT CODE and follow template given.