Ok, allow me to explain:
The first thing you want to do is take measurements:
Where do you want your car to start and where to stop and also what is the distance between those points?
You start with a tag that goes from 0 to 100.
First, you need to get that tag into the 0-1 range, like this:
Now all you need to do is multiply that by the range you want your car to move (let's say 250 units):
This gives you the formula for moving from point "0" to point "250" with accordance to battery level, but let's say you want it to start at 38 instead of on 0.
All you need to do is add it:
Thanks to this start of the range go from 0 to 38 and the end of it goes from 250 to 288.
Now you can do some cleaning inside of that script (I personally use http://www.wolframalpha.com/ especially with more advanced formulas):