Logic for rate approximation
Posted
by
Rohan
on Stack Overflow
See other posts from Stack Overflow
or by Rohan
Published on 2012-10-13T15:33:29Z
Indexed on
2012/10/13
15:36 UTC
Read the original article
Hit count: 241
approximation
I am looking for some logic to solve the below problem.
There are n transaction amounts : T1,T2,T3.. Tn.
Commission for these transactions are calculated using a rate table provided as below.
if amount between 0 and A1 -> rate is r1
if amount between A1 and A2 -> rate is r2
if amount between A2 and A1 -> rate is r3
...
...
if amount greater than An -> rate is r4
So if T1 < A1 then rate table returns r1 else if r1 < T1 < r2;it returns r2.
So,lets says the rate table results for T1,T2 and T3 are r1,r2 and r3 respectively.
Commission C = T1 * r1 + T2 * r2 + T3 * r3
e.g; if rate table is defined(rates are in %)
0 - 2500 -> 1
2501 - 5000 -> 2
5001 - 10000 -> 4
10000 or more-> 6
If T1 = 6000,T2 = 3000, T3 = 2000, then
C= 6000 * 0.04 + 3000* 0.02 + 2000 * 0.01 = 320
Now my problem is whether we can approximate the commission amount if instead of individual values of T1,T2 and T3 we are provided with T1+T2+T3 (T)
In the above example if T (11000) is applied to the rate tablewe would get 6% and which would result in a commision of 600.
Is there a way to approximate the commission value given T instead of individual values of T1,T2,T3?
© Stack Overflow or respective owner