CMSC 246 Systems Programming
Spring 2018
Assignment#8
Due in Class on Wednesday, April 18, 2018
- Airports!
Write a program that, given a database of all US airports (see details as well as how to get the data file from Lab 8), enables a user to search for airports by their code. Here is a sample output from such a program (called search.c)
[Xena@codewarrior] $ ./search code.txt
Able to open file: code.txt
Reading data...done [3376 airports!]
Enter the three-letter code for an airport: PHL
Success: PHL - Philadelphia Intl, Philadelphia PA (USA)
Would you like to search again (Y/N)? Y
Enter the three-letter code for an airport: LHR
Unsuccessful: PHL is not a known airport.
Would you like to search again (Y/N)? Y
Enter the three-letter code for an airport: 06U
Success: 06U - Jackpot/Hayden, Jackpot, NV (USA)
Would you like to search again (Y/N)? N
This was a databse of 3376 airports.
Goodbye!
Above, underlined text is user input.
You will make use of the following:
1. File I/O (using FILE, fopen(), fclose())
2. Command line arguments (see example above)
3. Using strtok() to parse the CSV file.
4. Your main data structure will be a linked list of airports (define a structure type Airport).
5. The linked list should have the functionality implemented in Lab 11. You may use/reuse the program/code provided for Lab 11 (on Wednesday, April 11). You may also use/reuse program/code from Assignment#6 however make sure that you have redefined the Airport data type to have no limits on the sizes of the strings. However, instead of copying the entire program/code, be sure to select ONLY the pieces you need for this assignment.
6.
You will need to define a new linked list function queryAirport() that, given the list of airports, and a three-letter code for an airport, searches and returns the airport that matches the code. If unseccessful, it returns a NULL. This function will be used to answer the user queries.
7. Use good design principles to design your program (think OOP design, but apply it to the design of this C program).
Make sure you have implemented each ADT in a separate set of .h and .c files. You will end up with at lest the following files: node.h, node.c, List.h, List.c, and search.c
Sample output: Once done, show your program's output for the following inputs: BMC, 172 (One Seven Two), 00M (Zero Zero Em), TCS, BUZ, 5A8, DAR, ZZV, 22M, PHL.
Scripting in Linux
Once done, you will need to show the sample runs of programs, as required below. In order to record the runs, you can use the Linux command script
.
Go to your Assignment directory and enter the command: script session
You will get your command prompt back. Next, run each of the above programs as you normally would. Once done, enter the command: exit
(or CTRL-D)
This will end your script session. If you now look a the contents of the session file, you will see that the entire interaction has been recorded in it (as a script!).
What to hand in:
- A printout of all the program files, including the Makefile.
- A prinout of the script file showing runs of your program for exactly the inputs specified above in Sample Output. Also, study the example interaction above. Your program should have exactly the same behavior shown.
- Write and print out a short 1/2-paragraph reflection on your thoughts on this lab (how this assignment went for you, what went wrong, etc.)
- Answer the following in your write up:
- How many airports in the database are not in the US? Give at least one example.
- Why did we not need a limit for sizes of strings? Or the size of the linked list?
- How would you determine the limit on the number of airports for your program?
Back to CMSC246 Home page