ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 8.00

information stored for an automobile at a car dealer

Hello, you helped me with my last question and it was very helpful, if you don't mind helping me with this one; it is a little longer but you'd have more time to answer it. 

The 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, and highway 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 the following attributes: 

o make                         string 

o model                        string 

o manufacture year    int 

o city mpg                   int 

o highway mpg           int 

You 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 28 

Jeep Wrangler 2016 17 21

 ... 

1. Name your program car.c. 

2. The program should be built around an array of structures, with each structure containing information of a car's make, model, manufacture  year, city mpg, highway mpg, and average mpg( average of the city mpg and highway mpg).  Assume the make and model are no more 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 boxes should be sorted by average mpg in ascending order. The function should have the following 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, in the following format. 

Make        Model       year   city mpg    highway mpg  average mpg 

Jeep         Wrangler  2016      17                      21                      19 

Mercury   Sable        2009     18                      28                     23 

...

 

Mercury Sable 2009 18 28Jeep Wrangler 2016 17 21Honda civic 2015 31 41Toyota Corolla 2015 30 42Toyta Prius 2010 51 48Ford Escape 2013 23 33Ford Fusion 2013 25 37Acura MDX 2014 20 28Lexus RX 2013 32 28

Attachments:

Answers

(11)
Status NEW Posted 08 May 2017 04:05 AM My Price 8.00

-----------

Attachments

file 1494217690-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)