Friday, 16 August 2013

Algorithm/Function about computing taxi fare

Algorithm/Function about computing taxi fare

Let's say that a taxi charges $3.10 for the first fifth of a mile. Then
for each additional fifth of a mile it charges half a dollar. For every
minute of waiting or delay it charges half a dollar. However, this delay
charge is applied instead of the mileage charge for each minute during
which the speed of the taxi is slower than the brea-even point. The
break-even point is the speed at which a fifth of a mile is driven in one
minute. We are assuming the taxi goes at constant speed. I am trying to
write an algorithm or function that takes in the total distance and total
time travelled by taxi and outputs the fare. However, I am having
difficulty factoring in the delay charge.
So if the taxi is going at constant speed then ideally it would travel x
miles during the time given (constant speed * time interval). If we
subtract the actual miles travelled from this value, we would get the
number of "wasted" miles that could have been travelled but were not. And
then I lose the train of thought and I am not sure where to go from there.
Any help/hint would be appreciated.

No comments:

Post a Comment