So our cost formula is:
C = 5 + .5d + 3.5
If we set this equal to the 28.5 in our pocket, we get
5 + .5d + 3.5 = 28.5
.5d = 20
d = 40
So, our answer is 40 miles. Incidentally, you should be able to see this intuitively as well. If you subtract the fixed costs from $28.50, you see that we have $20 to spend on mileage, which at $.5 per mile gets you 40 miles.