Fare calculator,
I’m working on creating a booking fare calculator.
There are 28
bus stations,
Base Price is 100
up to 5
bus stations.
Later 50
extra for every 5
bus stations.
Round trip from 1 to 28
is 300
.
Here is my solution,
BASE = 100
stops = (start - end).abs
case stops
when 1..5
BASE
when 5..10
BASE + 5
when 10..15
BASE + 10
when 15..16
BASE + 15
when (station_array.length - 1)..station_array.length
200
end