icon

Usetutoringspotscode to get 8% OFF on your first order!

he information stored for an automobile at a car dealer are saved in the file cars.txt

he information stored for an automobile at a car dealer are saved in the file cars.txt.Each line contains the record for a car including the make and model, manufacture year, city mpg, andhighway mpg. Write a program that reads file cars.txt, store the data in an array of car structures,and sort the cars by average mpg (the average of city mpg and high way mpg). Output the sorted cars,including the average mpg in a text file called sorted_cars.txt. A car structure should have thefollowing attributes:o make stringo model stringo manufacture year into city mpg into highway mpg intYou can assume the cars.txt as the following format for each car: make (one single word), model(one single word), manufacture year, city mpg, highway mpg.Mercury Sable 2009 18 28Jeep Wrangler 2016 17 21…1. Name your program car.c.2. The program should be built around an array of structures, with each structure containinginformation of a car’s make, model, manufacture year, city mpg, highway mpg, and averagempg( average of the city mpg and highway mpg). Assume the make and model are nomore than 30 characters. Assume that there are no more than 1000 cars in the file.3. Use fscanf and fprintf to read and write data.4. Modify the selection_sort function provided to sort an array of product struct. The boxesshould be sorted by average mpg in ascending order. The function should have thefollowing prototype:void selection_sort(struct car cars[], int n);5. Output the sorted cars, including average mpg, in a text file called sorted_cars.txt, inthe following format.Make Model year city mpg highway mpg average mpgJeep Wrangler 2016 17 21 19Mercury Sable 2009 18 28 23

Need assistance with this?

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes