You are given a dataset about some all-wheel-drive cars and how much fuel they use. “I’m gonna attach it in excel because i cant attach a .cvs file but then i can send it in a zip file
Write a program to find the top 10 cars with highest city mpg. Write the results in the output file.
The input file is a CSV file with the following fields for each car:
Identification (String), Classification (String), Engine Type (String), Transmission (String), City
mpg(Integer), Fuel Type (String), Highway mpg(integer). Fields are separated by comma, with each car
on a separate line:
2009 Audi A4 Sedan 3.2, Automatic transmission, Audi 3.2L 6 cylinder 265hp 243ft-lbs, 6 Speed Automatic Select Shift, 17, Gasoline, 26
….
Classification: whether this is a “Manual transmission” or an “Automatic transmission”. If it is unknown,
it is left blank.
Identification: a unique ID for this particular car, using the year, make, model, and transmission type.
Example input/output:
Enter the file name: cars.csv
Output file name:
Top10_city_mpg.csv
Technical requirement:
1. Name your program cars_mpg.c.
2. The output files should be the named Top10_city_mpg.csv.
3. Assume that there are no more than 6000 cars in the file. Assume that each field is no more
than 150 characters.
4. Use fscanf and fprintf to read and write data. To read all fields of a car, use the following
conversion specifier for fscanf:
“%[^,], %[^,], %[^,], %[^,], %d, %[^,], %d\n“
5. The program should be built around an array of car structures, with each car containing
information of engine type, transmission, city mpg, fuel type, highway mpg, classification,
and identification.
6. Your program should include a function that sorts the cars by city mpg. You can use any
sorting algorithms such as selection sort and insertion sort. Note that with different sorting
algorithms, the result might differ when city mpg are the same.
void sort_city_mpg(struct car list[], int n);
7. Output file should be in the same format as the input file, with the members separated by
comma and each car on a separate line.
2012 Subaru Impreza Hatchback 2.0i, Manual transmission, Subaru 2.0L 4 Cylinder 148 hp 145 ft–lbs, 5 Speed Manual, 25,
Gasoline, 34
…..
Order an Essay Now & Get These Features For Free:
Turnitin Report
Formatting
Title Page
Citation
Outline