Project 3 - Airline Management
0. Getting Started
1. Optional Introduction to C++ and Programming Concepts
2. So… How Do I Use and Code in C++
3. Inputs, Outputs and Comments
4. Initialization of Variables
5. Other Data Types
6. Number Operators
7. Control Flow
8. Vectors
9. Functions
Project 1 - Statistics Program
Project 2 - Rocket Simulation
Project 3 - Airline Management
(To start this project, make a new file on the compiler and use “#include <vector>”)
You are the CEO of Wolverine Airlines, an international airline based in Detroit Airport (DTW). You have one extra Boeing 777 airplane and plan on using it to start a new route from Detroit. There are 5 different destinations your employees have shortlisted for you: New York, San Francisco, Paris, Hong Kong, and Cape Town. Your job is to use C++ to analyze which route is the best, given the following information. (Fun Fact: The information below is based off actual numbers, but simplified - this should give you a basic idea of how airlines plan their routes and set their ticket prices)
General Information
The distances between Detroit and the 5 destinations are:
The (average) speed of the Boeing 777 is 590 miles per hour
The flight time (in hours) can be found by dividing the distance by the speed
A Boeing 777 uses 5 gallons of fuel per mile traveled (fuel consumption rate)
A gallon of fuel weighs 6 pounds per gallon (density)
A Boeing 777 has a maximum capacity 420 passengers
Due to the COVID-19 situation, passenger demand for air travel is low. Thus, although the Boeing 777 has a maximum capacity of 420 passengers, the predicted passenger load factors (percentage of maximum capacity actually filled on a plane) for the 5 proposed destinations are lower - in other words, this represents how full the flights will be. A 100% load factor means that the flights will be full, while a 0% load factor means flights will be empty.
(Note on load factor: For example, if the load factor is 20%, then 20% of the 420 seats are filled, so there are 84 seats demanded/filled and 336 empty seats on a flight.)
The average weight of a passenger is 137 pounds.
For any given flight, 44400 pounds of cargo are transported in the cargo hold
The empty weight of the Boeing 777 is 353600 pounds. The empty weight is the aircraft’s body weight (weight of fuselage, wings, landing gear, seats etc. without fuel, passengers and cargo)
Cost Information
A gallon of jet fuel costs $1
There is a landing fee at the destination airport based on your aircraft’s original weight (before takeoff). The fee is determined by the airport and is different for each destination, depending on how busy the airport is (the busier the more expensive).
(Note: For example, if my original weight before takeoff (weight including fuel, passengers, aircraft body etc.) is 1000 pounds, landing at Paris costs 0.01*1000=$10, while landing at New York costs 0.012*1000=$12)
There are 25 staff needed for any flight (regardless of destination). They are paid $35 per hour of flight time.
There are other costs for a flight based on the distance (in miles) travelled - these include maintenance, insurance, food, baggage handling fees, air traffic control fees etc. Such costs (in $) amount to 25 times the distance travelled. For example, such costs for a flight to a destination 1000 miles away is $25000.
Revenue Information
Your employees have done research and found the most suitable ticket prices for the 5 destinations:
(Note: These prices are usually found by looking at competing airlines, cost calculations and demand for the route)
Profit Calculations
The total cost for operating a flight can be found by summing the fuel costs, landing fee, staff wages and other costs (mentioned in cost section). Note that these depend on many factors, like distance, load factor, travel time etc.
Total Cost = Fuel + Landing Fee + Wages + Other Costs
The total revenue (how much you get from tickets) for a flight can be found by multiplying the total number of passengers on the flight by the ticket price.
Total Revenue = Passengers * Ticket Price
The profit Wolverine Airlines makes from a flight can be found by subtracting the total costs from the total revenue (i.e. your profit is how much you gain from ticket sales, minus your operating costs for the flight)
Profit = Total Revenue - Total Cost
Government organizations charge a 20% tax on the profit gained each flight. The actual profit Wolverine Airlines gets after tax is called Net Profit.
Wolverine Airlines cares about two performance indicators for a route: net profit per passenger (NPPP) and net profit per flight hour (NPPH). Net profit per passenger (NPPP) is found by dividing net profit by number of passengers onboard, and net profit per flight hour (NPPH) is found by dividing net profit by the number of hours the flight takes.
NPPP=Net Profit / Passengers
NPPH=Net Profit / Flight Time in Hours
All units should be in either pounds (lbs.), dollars ($), hours (hrs.) or miles (mi.)
Store all the given information by initializing variables and assigning values - you may choose to use doubles, vectors or other data types.
DO NOT initialize anything as an “int” in this case (use doubles), as even though some values may be ints (e.g. distances), when you do divisions and multiplications on ints, they round to an int and don’t give you an exact answer, even if you declare your answer as double. Note that an int can always be declared as a double as the digits after the decimal place for an int are just 0.
Hint for all the steps below: You may be able to do this exercise with ‘brute force’ but it may be easier to do it by initializing empty vectors for things you want to calculate (e.g. flight time) then use for loops to do the same calculations for each destination and store the result in an appropriate location in the vector. Also, if you are unsure, you can print out the intermediate calculated values to check if they’re reasonable.
Calculate the flight time for each of the 5 destinations.
Use the load factors to calculate how many passengers will take a flight to each of the 5 destinations.
Calculate how much the passengers weigh (total passenger weight) for flights going to the 5 destinations - this can be found by multiplying the number of passengers by the average weight of a passenger. Note that because the number of passengers are different for each destination, the weights are different too.
Calculate how many gallons of fuel are needed for the 5 destinations.
Calculate the total fuel weight for flights to the 5 destinations. This is the weight of fuel the plane needs to carry, ignoring spare fuel to be safe.
Calculate the total weight of a flight to each of the 5 destinations - this can be found by summing the empty weight, fuel weight, passenger weight and cargo weight.
Find the fuel cost for flights to each of the 5 destinations (Hint: Use the gallons of fuel needed for the destinations and cost per gallon of fuel)
Find the wage cost for flights to each of the 5 destinations (Hint: Use the flight time for the destinations and wage cost information above)
Find the landing cost for flights to each of the 5 destinations (Hint: Use the total weight for flights to different destinations found in part 7 and the landing fee information)
Find the “other” costs for flights to each of the 5 destinations. (Hint: Use the information above and the distance traveled)
Find the total costs to operate flights to each of the 5 destinations
Find the total revenue gained from operating flights to each of the 5 destinations
Find the net profit (profit after 20% tax) gained by flying to each of the 5 destinations
Find the net profit per passenger and net profit per hour for each of the 5 destinations.
Print out a report/statement of the results (using cout). Assign each of the destination numbers in your report to make this easier (e.g. Destination 1 is New York). Your report should include for each destination:
The flight distance
The flight time
Number of passengers
Net profit per passenger
Net profit per hour
If the destination is viable (positive net profit). Hint: Use if statement and cout
Test the report out to make it more readable (use one endl to skip to next line or two endl’s to separate with blank line).
17. Calculate which destination (destination number) has the highest net profit per passenger (NPPP) and which destination has the highest net profit per hour (NPPH). Hint: Initialize 2 ints that store the destination number of the destination that has the highest NPPP and NPPH - set these initially to destination 1 (i.e. values assigned to the ints represent destination 1). Then, using a for loop that loops over all other destinations, compare the NPPP and NPPH of the other destinations to the NPPP and NPPH of the destination stored in the ints. If the NPPP and NPPH of some other destination is larger than the NPPP and NPPH of the destination stored in the int, replace the destination (number) in the respective int with the respective destination number. At the end of the loop, the 2 ints should store the destination numbers of the destinations with the highest NPPP and NPPH.
18. Print out which destination is the best in terms of net profit per passenger (NPPP).
19. Print out which destination is the best in terms of net profit per hour (NPPH).
20. Most airlines make around $10 to $20 net profit per passenger (NPPP). They also say that long haul flights earn more than short haul flights. Do your results agree with this?
Solution Code & Output:
Extension
21. Optimize your code to make it shorter and more efficient (try to see if you can combine for loops together or use vectors/for loops to make it more efficient)
22. Edit your code so that instead of using the numbers/information provided above, your program asks the user for the destinations’ distance, load factor, landing fee and ticket price. In other words, allow user input for these 4 parameters so that your code can be used for more destinations and your code is more user friendly.
Use cout to ask the user for information (e.g. “Enter destination distance”) then use cin for user input to get the information
Previously, we assumed that there are 5 target/prospective destinations. Now, any number of destinations is possible (as low as 1, up to infinity). You should first ask the user how many destinations they are considering and set up your code accordingly (think vector initialization and for/while/if loops)
The other parameters remain the same - passenger data, aircraft data, fuel data etc. are the same and don’t change depending on the destination.
Hint: Think about what the best way to implement this is. You should first ask the user for how many destinations are considered before initializing anything. What would then be the best way to store data when you have a variable/changing input size?
Remember to print the report (steps 16-19) at the end of your code