Question: C++ with no classes. Problem description You have a database of flights in a following format. From To Price ($) Distance (mi) Austin Houston 109



Problem description You have a database of flights in a following format. From To Price ($) Distance (mi) Austin Houston 109 1 140 Washington D.C. Seattle 139 421 Austin New York 94 1511 Dallas Austin 93 74 Chicago Las Vegas 149 1039 Where "From" column contains a city of departure and "To" col- umn contains a city of arrival. "Price" column has a ticket price in dollars and "Distance" column contains a straight line distance be- tween two cities. The database is stored in a CSV (comma-separated values) file It's a file format used to store tabular data. Rows are separated with an endline symbol and individual values are separated by comma. Note, values stored cannot contain comma or endline symbol. See "flights.csv" for an example. The objective is to write the program that can help you process the database. Your program should be able to (1) display the database in a readable format, (2) show flights that depart from a given city, (3) find the flight with the best distance to price ratio and show it together with the ratio. Note: you can assume that your input file has no more than 100 flights stored, so you can create an array of flights with 100 elements in it and then use only as many as you read from the file. Implementation The program should run in a while loop. Each iteration the program should ask to enter the menu option (1-4). Depending on the menu option the program should do the following: 1. Show all the flights in a database in a human readable format. 2. Ask for a city name. Then show the flights that depart from that city. 3. Print the best (highest) distance to price ratio and a flight that has it. 4. Exit the loop. The program should contain at least 4 functions (excluding main). 1. "readFlights". Given the file input stream, and empty array of flights, read the .csv file with flights and return a size of an array. 2. "print Flights". Given the array of flights and its size it prints the array 3. "print FlightsFrom". Given the array of flights, its size and a city name it prints flights from the given city 4. "find Highest Distance To PriceRatio". Given the array of flights, its size and "flight_index" integer passed by reference it finds the highest distance to price ratio, puts the index of the re- spective flight into "flight index" variable and returns the ratio. IMPORTANT: It should not print anything. If more than one flight has the highest ratio, your program should output one of these flights. Please do not use any features of C++ that we have not yet covered in class. Do not use classes
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
