Question Details

(Solved) Please note: I'm writing C in the c89 standard. The information




Please note: I'm writing C in the c89 standard.

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 manufactureyear int
o citympg int

o highwaympg 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 ...


Before you submit:

1. Compile with -Wall. Be sure it compiles on circe with no errors and no warnings.

gcc -Wall car.c

2. Be sure your Unix source file is read & write protected. Change Unix file permission on Unix:

chmod 600 car.c

3. Submit both car.c and cars.txt (for grading purposes).



Mercury Sable 2009 18 28

 

Jeep Wrangler 2016 17 21

 

Honda civic 2015 31 41

 

Toyota Corolla 2015 30 42

 

Toyta Prius 2010 51 48

 

Ford Escape 2013 23 33

 

Ford Fusion 2013 25 37

 

Acura MDX 2014 20 28

 

Lexus RX 2013 32 28

 


Solution details:

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Oct 15, 2019

EXPERT

Tutor

ANSWER RATING

YES, THIS IS LEGAL

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN A DEADLINE.

Order Now