CSC 110 – Programming Project Airline Flight Scheduling


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (7 votes)

The objective of this project is to write a program in Python that will read in a data
file with all flights from Providence to Orlando and display information requested by
the user.
The Data:
The data file can be found here:
This .csv file contains the following information for flights from Providence to
The name of the airline, which is represented as a string.
Flight Number
Each airline has a unique flight number assigned to a particular flight. Each airline
may have more than one flight scheduled on the same day from Providence to
Departure Time
The time of day that the flight is scheduled to depart from Providence. Time is
represented in 24 hour clock time, so 14:00 represents 2:00PM.
Arrival Time
The time of day that the flight is scheduled to arrive in Orlando.
The cost of the flight.
The Program:
For this assignment, you will present the user with a list of options and you will
display the results of the action chosen by the user. The program should continue to
run until the user chooses to quit. The menu that you present to the user should
look like this:
As you can see from the image, there are 7 different options offered to the user. Here
is a brief description of each.
1 – Find Specific Flight
This option asks the user to enter an airline and a flight number, and then displays
for the user the information about that flight. If the user enters an airline or flight
number that does not exist, the program should let the user know.
2 – Flights Shorter than a Specified Duration
This option will ask the user to specify a maximum flight duration and then display
flight information for each of the flights whose duration is less than or equal to that
maximum. Duration is computed by taking the difference between the arrival time
and the departure time.
3 – Cheapest Flight by a Given Airline
This option finds the flight with the lowest price flown by a specified airline and
displays the information for that flight. The user should be prompted to enter an
airline and then the program should make sure the user chooses a correct option.
You may not use the built-in min function or sort function.
4 – Flights Departing After a Specified Time
This option will provide the user with a list of flights that depart after a specified
time. Your program should ensure that the time entered by the user is in a valid
time format. That is, the user input should be in the HH:MM format where HH is
between 00 and 24 and MM is between 00 and 60.
5 – Average Price of All Flights
This option finds the average price of all available flights. You may not use the
built-in sum or average functions.
6 – Sort All Flights by Departure Time and Write to a New File
This option creates an output file called time-sorted-flights.csv, and writes
to the file the flights sorted by departure time. Note that you should not change the
sorting order of the lists in your program. Rather, you should create a list of indexes
that you sort based on the order of the departure time. You can use any sorting
algorithm that you like. You may not use the python built-in sort function.
You are required to use functions when writing this program. You will have some
freedom to design your functions. One requirement is that the functions that
perform tasks requested by the user should NOT print their results. Rather, they
should return the requested values to the main function, and have a separate
function that prints the results. You should have a main function with no
parameters and no return values. Do not include a call to the main function in your
code because Gradescope will not be able to test it if you do.
User Input
Any time the user is asked for input, your program should check to make sure the
input is valid. You can use exception handling to handle cases where the bad input
will cause the program to crash. You can use the in function to check that user
input is found in the list in question. For example, if you are asking the user to enter
the name of an airline, you can use the following to check if the airline name is in the
list of airlines in the data file:
if airlineName in airlineList:
Program Requirements:
Your program should meet the following requirements:
1) Your program should work correctly. Your program should do at least the
following correctly:
a. Display the menu of options to the user.
b. Ask the user to make a choice.
c. Execute the choice made by the user and display the results.
d. Continue until the user chooses to quit.
e. Display an error message if the user chooses an invalid option and
allow the user to try again.
2) Your program should use good modular design. It should use functions for
each of the main tasks of the program. Note that some of the tasks in this
program are very similar, and if you design your code carefully, you can use
the same function to perform several of the options the user may choose.
3) Your program should be well-documented. This should include your name
and an overall description of the program at the top of the file. It should also
include a description of any algorithms that are used in the code.
4) Your program should use well-named functions and variables. The code
should be simple to read and understand what is going on given the names of
the functions, and variables along with the comments in the code.
The following screen shots show you what the results should look like for each of the
options on the menu.
Check for Valid Input
1 – Find Specific Flight
2 – Flights Shorter than a Specified Duration
3 – Cheapest Flight by a Given Airline
4 – Flights Departing After a Specified Time
5 – Average Price of All Flights
6 – Sort All Flights by Departure Time and Write to a New File
The output file should look like this:
Notes and Hints:
1) As mentioned in option 6 above, you may not use the python built-in sort
function to sort your data.
2) You may not use the python built-in index function to find an item in a list. You
should write the search code yourself.
3) You should create a separate function that will print the results. So the functions
that you write to implement each of the menu options will NOT print results.
They will return the appropriate information so that you can print the results
from either the main function or some other function that calls the computation
functions. Be sure to design your print function so that it will be able to print
any of the types of results that might be returned.
4) Departure and arrival times are stored as strings. You will need to write a
function to convert a time string like ‘10:34’ to an integer so that you can do
comparisons and sort based on these times. Since all of the times are assumed to
be in the same day, you can compute a numeric time that represents the number
of minutes since the beginning of the day. So ‘10:34’ would be 10 hours and 34
minutes since the beginning of the day, which is 634 minutes since the beginning
of the day. Your function should take the time string as a parameter and return
the numerical time value.
5) Here are a few hints about how to sort your data by departure time:
a) The parameters of the function should be the list of departure times. The
function should return a list of indexes sorted by rearranging them the same
way you will rearrange the departures list. That is, suppose the departures
list looks like this:
You should create a list of indexes as follows:
Then your sorting algorithm will rearrange the list of indexes the same way
the list of departure times will be rearranged, so we would end up with:
Your function will return this list of indexes.
b) You will have another function that takes as a parameter the list of indexes
and all of the other lists and writes to an output file with all of the lists in the
order specified by the index list.
6) To make a copy of a list, use the following syntax:
newList = oldList.copy()
If you have lists inside the list, then you will need to make a deep copy. This does
a recursive copy and copies all lists that are inside of the original list:
newList = oldList.deepcopy()
7) To format your output, you can use the following syntax:
print(airlines[i].ljust(8), flnums[i].ljust(6),
rjust(7) justifies the text to the right and allows 7 characters for it
ljust(8) left justifies the text (that is the letter L, not the number 1 at the
beginning of the function name)
You can only justify a string, so if you want to print an integer or float, you have
to convert it to a string first.
What to Submit:
Please submit your code in a file called to Gradescope in the
assignment called Programming Project – Airline Scheduling.
NOTE: DO NOT use Gradescope to test and debug your code. You should be doing all
of your testing and debugging in IDLE. Once you are confident that the code is
correct, you can submit to Gradescope.
Grading the Assignment:
See the Grading Rubric for the Airline Programming Project to see how the
assignment will be graded.