Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use structure in C++ Problem description 74 You have a database of flights in a following format. From 1 To Price ($) Distance (mi) Austin

image text in transcribedimage text in transcribedimage text in transcribed

Use structure in C++

Problem description 74 You have a database of flights in a following format. From 1 To Price ($) Distance (mi) Austin Houston 109 140 Washington D.C. Seattle 139 421 Austin New York 1511 Dallas Austin 93 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

More Books

Students also viewed these Databases questions