Please help me find the simplest formula in getting the fare. I can get the fare using layman's calculation (i don't know if that is the correct term) but what I need is a formula. I'm stuck with what I did and I thought that this is the best place to get help. I think it's best to explain this is through example. So,
Problem: Find fare of passenger who will travel a total distance of 12km.
Tiered Fare Matrix:
| TIER 0 | TIER 1 | TIER 2 | TIER 3 | TIER n
incremental distance (m)| 1000 | 3000 | 3000 | 3000 | dn
rate ($/m)| 0.2 | 3 | 2.5 | 2 | rn
where,
TIER 0 is the lowest tier or the starting point
$m$ = meters
$r$ = rate
$d$ = distance
dn = ${d_n}$ = nth distance
rn = $r_n$ = nth rate