"The Trip" challenge from Programming Challenges
Your algorithm seems to be correct though a bit overcomplicated.
But the code is not correct. consider:

9999.1
9999.1
9999.0
9999.1

$0.05


And the correct answer is $0.07

This is due to lack of precision in float implementation. It does not mean you should use double, it mean you should check your casts and try to avoid using float at money computations at all.

Also, i suggest to check your inputs.