I drove 280 miles, made up of both highway and city driving. I used 15 gallons of gas that cost $3.15 per gallon. If my car gets 24mpg highway and 16mpg city, how much did it cost me for the highway portion of the trip, and how much for the city portion
of the trip? Explain work.

let x= # of gallons used driving on the highway

let y= # of gallons used driving in the city

x+y=15

24x+16y=280

if x+y=15, then y=15-x

substitute y=15-x in the second equation

24x+16(15-x)=280

24x+240-16x=280

8x+240=280

8x=40

x=5 gallons used on the highway

5+y=15 and y=10

y=10 gallons used in the city

check: (5x24)+(10x16)=280

120+160=280 miles

5x$3.15=$15.75 for the highway cost

10x$3.15=$31.50 for the city cost

check: 15x$3.15=47.25 and $15.75+$31.50=$47.25

By the way, if you want to determine your average gas mileage and you drive the same number of miles in the city as on the highway, you can use a special case of what is called the harmonic mean., For example, if you get 10 mpg in the city and 15 mpg
on the highway and you drive 30 mile in the city and 30 miles on the highway, you use 3 gallons of gas in the city and 2 gallons of gas on the highway. Therefore you use 5 gallons altogether(3+2) and you drive 60 miles altogether(30+30).

Therefore 60/5=12 mpg. Using the special case of the harmonic mean, we have (2xrate#1xrate#2)/(rate#1+rate#2)=(2x10x15)/(10+15)=

300/25=12 mpg

Using your problem, we have (2x24x16)/(24+16)=768/40=19.2 mpg.

This is your

*average*miles per gallon if you drive the same distance in the city as on the highway. Another example:20 mpg city and 30 mpg highway-(2x20x30)/(20+30)=1200/50=24 mpg*average*Notice the average is always closer to the city mpg !