Hi,
Work:

To find the cost of gallons spend for 310 miles you need to first find the amount of gallons consumed on 310 miles path.

If each costs 3.5$ you need to multiply gallons with money.

You would spend 38.745$ to drive 310 miles.
Hope this helps.
r3t40