Homework: Taxi Trips Overview Many cities make available to the public data on transportation services such as bike-sharing, taxis, buses, and subways. The datasets can be useful for several purposes,...

We can only use Arrays for the assignment.


Homework: Taxi Trips Overview Many cities make available to the public data on transportation services such as bike-sharing, taxis, buses, and subways. The datasets can be useful for several purposes, including identifying patterns and trends that can help predict the demand for transportation systems. This homework works with taxi trip data. Your program needs to read a file with information on taxi trips and output a summary of the data. Input data format For each taxi ride, the file contains the following information: taxi_id trip_seconds trip_miles trip_fare trip_tip payment_type   where:   ● taxi_id : a string that identifies the taxi providing the ride ● trip_seconds : the ride duration in seconds ● trip_miles : the driven distance in miles, when available. If not available, the number is reported as zero. ● trip_fare : the cost of the trip ● trip_tip : the tip provided by the customer ● payment_type : a string with one of the following values: “CreditCard” , “Cash” , “NoCharge” , “Unknown”   The input files are “cleaned up” by the government agency providing the data, but they still may present errors. In this homework, you are expected to handle only the following invalid scenarios: ● Values for trip_seconds that exceed 24 hours. ● Values for trip_miles that exceed 1500 miles. ● Values for trip_fare + trip_tip that exceed 5000 dollars. ● Value for payment_type that is not “Credit Card” , “Cash” , “NoCharge” , or “Unknown” . ● Values for trip_seconds and trip_miles are both zero but trip_fare is not zero. Any trip containing invalid data must be ignored, i.e., they are not included in the calculators for the output report. Again, you do not need to cover other invalid input scenarios, such as the file containing a non-number text when a number is expected. The maximum number of rides in an input file is MAX_TRIPS (defined in the starter code as a global constant in taxi_trips.h )   1 An example of an input file Taxi_0 660 1.1 9.05 4 CreditCard   Taxi_1 300 1.0 5.25 0 Cash   Taxi_2 540 1.1 800.01 4200 Cash   Taxi_3 360 1.85 5.45 2 CreditCard   Taxi_4 180 1.1 4.65 0 Cash   Taxi_5 60 1.0 3.25 0 Cash   Taxi_2 300 1.8 6.05 3.95 Cash   Taxi_7 840 2.8 10.45 3 Cash   Taxi_8 1080 9.3 21.05 5 Cash   Taxi_1 600 0.9 4.25 0.75 Unknown   Taxi_21 3600 40 121.11 20 CreditCard   In the example listed above, the file contains information from several rides. The first one, by taxi Taxi_0, has a duration of 660 seconds, distance of 1.1 miles, fare cost of $9.05, tip of $4, and it was paid by credit card. The third ride in the file, by Taxi_2, is invalid because the fare + tip exceeds 5000 dollars. Output data format Your program needs to generate as output a report with the following information: ● Total number of trips in the file ● Number of trips with invalid data ● Average and mode for trip duration, distance, fare, and tip 1 ● Distribution of payment types, with percentages rounded to the nearest integer The data must be reported with the format in the example below. An example of output data For the input file example above, the program would write to standard output the following: Number of trips: 10   Number of trips with invalid data: 1   Duration: max 3600 min 60 avg 798 mode 300   Distance: max 40 min 0.9 avg 6.085 mode 1.1   Fare: max 121.11 min 3.25 avg 19.056 mode 9.05   Tip: max 20 min 0 avg 3.87 mode 0   Length of longest sequence without tips: 2   1 The mode is the most frequent value. Read more on Wikipedia .   2 https://en.wikipedia.org/wiki/Mode_(statistics) Objectives 1. Practice using C++ file input in a simple scenario. You will work with more complex data validation scenarios in upcoming labwork and homework assignments. 2. Initial practice with: a. Using C++ arrays to store data b. Writing functions that
Sep 22, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here