Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Details Data For this project we are going to be using a set of data that representing flight data from 1990 - 2009. The complete

Details

Data

For this project we are going to be using a set of data that representing flight data from 1990 - 2009. The complete set of data has over 3.5 million records. We will only be using parts of it for our testing for the sake of time. However, if you can write a successful project for the smaller data set it should work for the complete data set. Ill post a link to the complete data set at the end for anyone that is interested in it.

The data has 11 fields that are described here:

Origin - string - 3 letter airport code

Destination - string - 3 letter airport code

Origin City - string - origin city name

Destination City - string - destination city name

Passengers - integer - the number of passengers on the flight

Seats - integer - the number of seats available on the flight

Flights - integer - the number of flights between the origin and destination for the given month/year combination

Distance - integer - distance (to the nearest mile) flown between the origin and destination

Fly Date - integer - The date (yyyymm) of flight

Origin Population - integer - Origin citys population as reported by U.S. Census

Destination Population - integer - Destination citys population as reported by U.S. Census

Snippet

CLE ERI Cleveland, OH Erie, PA 0 0 56 98 200703 2099185 279804 DLH ERI Duluth, MN Erie, PA 44 173 1 678 200703 273889 279804 DAY ERI Dayton, OH Erie, PA 33 50 1 259 200712 839563 279804 EWR ERI Newark, NJ Erie, PA 0 122 1 326 200708 18901167 279804 ALB ERI Albany, NY Erie, PA 19 37 1 329 200703 852019 279804 CAK ERI Akron, OH Erie, PA 0 120 1 104 200708 700559 279804 ERI ERI Erie, PA Erie, PA 104 112 1 0 200701 279804 279804 RNO ERI Reno, NV Erie, PA 143 150 1 2065 200704 410616 279804 ACY ERI Atlantic City, NJ Erie, PA 97 122 1 345.0 200712 269945 279804 ACY ERI Atlantic City, NJ Erie, PA 108 120 1 345.0 200707 269945 279804 

The data is a tabbed separated data file. So between each part of the data is a tab character (\t). You can/should watch the How To Read Tab Delimited set of videos for more information on how you can read in this type of data. Those videos are intended to give you an idea on how to get started.

In addition to the data file, we will have another input file in the form of a command file. In fact, the command file will be the input to the program.

The commands will have your program use a given data file to search for and summarize various pieces of information about the given input data file. The commands are detailed here:

Commands

c2c - this command will be followed by 2 strings. The strings represent a potential origin and destination airport codes. You are to search the given data file for any line that matches the given pair of origin and destination codes. If you find a match, then you are to show the information about the flight that matches the origin and destination. You may find many matches. Additionally, when you have checked all the data in the file, you are to summarize the number of flights, average number of passengers per flight, average number of seats per flight, and average number of flights. If the origin and destination cities arent found then an error message is output.

citySummary - this command is followed by an airport code. If the airport is found, then a summary of information about the city is given. You will show the total number of flights, number of inbound flights, number of outbound flights, average number of passengers per flight, average number of seats, and average number of flights. If the airport code is not found, then you issue an error message.

smallest - this command will search the data file and find the smallest airport by population. This will use both destination and origin population to find the smallest. Once the file is processed you will output the information about the smallest city.

largest - this command will search the data file and find the largest airport by population. This will use both destination and origin population to find the largest. Once the file is processed you will output the information about the largest city.

cityInfo - this command will be followed by a word, or words, and you are to match them with a city in the file. If the city is found, then the airport code and city name are displayed. The word, or words, may partially match either the origin or destination city names. Use find on those variables to search within the strings. Once you have found a match, you may stop looking. We will only match to the first one we find. If no matching city is found, an error message will be displayed.

datafile - this command will be followed by a filename. It is the file you are to use to do the searching. All you need to do is store it and pass it to the functions you write to perform the searches. Those functions should open it to search.

Additionally, for each of these command you need to echo the word Command:, the command itself, and arguments that are given. See the same output for more information about this and for what the error messages should be.

Input

So there are really two input files for our program. The first is the command file, it will be passed to our function via the input parameter. The second is the data file that is to be used for the searching. It will be listed in the command file after the datafile command. The datafile command may never occur or may occur once or more times.

Sample Command File

datafile flight_edges.tsv c2c ROA CLT c2c NOT ME! citySummary ROA citySummary WHERE smallest largest cityInfo Roanoke cityInfo WHERE? 

Output

If you were given the command file above here is (most) of the output. I trimmed the output from the c2c ROA CLT command since it has over 800 lines.

Command: datafile flight_edges.tsv Command: c2c ROA CLT Origin Destination Origin City Destination City Passengers Seats Flights Distance Date Origin Pop Dest Pop ROA CLT Roanoke, VA Charlotte, NC 318 1057 7 155 12/1990 269195 1029829 ROA CLT Roanoke, VA Charlotte, NC 7197 15070 137 155 12/1990 269195 1029829 ROA CLT Roanoke, VA Charlotte, NC 7219 12320 112 155 3/1990 269195 1029829 ROA CLT Roanoke, VA Charlotte, NC 111 432 4 155 3/1990 269195 1029829  ROA CLT Roanoke, VA Charlotte, NC 1626 2050 41 155 12/2009 300399 1745524 ROA CLT Roanoke, VA Charlotte, NC 1365 1961 53 155 12/2009 300399 1745524 ROA CLT Roanoke, VA Charlotte, NC 1980 2750 55 155 11/2009 300399 1745524 ROA CLT Roanoke, VA Charlotte, NC 1100 1680 24 155 11/2009 300399 1745524 Total # of flights: 858 Average # of passengers: 1851.04 Average # of seats: 3244.59 Average # of flights: 44.2145 Command: c2c NOT ME! Sorry no flights between NOT and ME! Command: citySummary ROA Total # of flights: 9943 # inbound flights: 4977 # outbound flights: 4966 Average # of passengers: 987.941 Average # of seats: 1832.73 Average # of flights: 34.1203 Command: citySummary WHERE Sorry no flights for WHERE found. Command: smallest Origin Destination Origin City Destination City Passengers Seats Flights Distance Date Origin Pop Dest Pop HNL AWX Honolulu, HI Andrews, TX 0 173 1 3466 7/2002 882628 12887 Command: largest Origin Destination Origin City Destination City Passengers Seats Flights Distance Date Origin Pop Dest Pop LGA CAK New York, NY Akron, OH 134 137 1 396 12/2009 38139592 699935 Command: cityInfo Roanoke Airport Code: ROA City: Roanoke, VA Command: cityInfo WHERE? Sorry no information for WHERE? found. 

So you can see for this example, I used the complete flight_edges.tsv file. I will not give you the complete file one web-cat, as it is very large. I will be giving you smaller ones that come from the complete file. If you can handle the complete file, then you can handle any of the smaller ones.

Requirements

Below is the list of requirements. You can receive these points even if your code is not working and if you dont follow these requirements you wont score a 100.

You must declare void flightData( string input, string output ); in a file named flight.h

You may not store the data from the files in an array, list, vector, etc. or any storage container from the STL.

You may not use the STL.

You must write a function for each of the commands listed above. The only exception is the datafile command. The datafile command does not need a function.

I highly recommend you write a function to read one line from the data file and a function to output a single record. It will help.

You may not use a struct, class, or other user-defined data type to store the records.

You may not store the data in an array, simply process it sequentially in each function.

You may not use pointers.

You may not use global variables. <== This is a big oneask if you dont know how to pass parameters correctly.

You may not write your code in the h file, write it in the cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions