Average fuel price of $3.00 per gallon
Fuel Effic MPG Dollars per Mile Distance MILES COST dollars
City 28 3/28 x (3/28)x
Highway 39 3/39 y (3/39)y
Total 1543
The cost of the trip depends on two variables for distances x and y.
Total cost:
You could take this another step and use
substituting that,
----and simplify this if you want, and have the cost in terms of the city miles distance, keeping the constant total trip 1543 miles.