How to make N equal instalments of any amount?

31 Views Asked by At

I am working on a financial software, in it I would like to offer an option of paying for an item in 3,6 or 12 instalments. I would be deducting each instalment amount via there Credit Card every month.

for example if I have an item that costs $700, and I want to make 12 instalments. each instalment comes out to be, 700/12 = 58.3333333333.

Now If i use 58.33, 58.33*12 = 699.96.

If i use 58.34*12 = 700.08

I cannot store the amount 58.3333333333 becuase when using payment gateways they require the amount to be mentioned nearest 2 decimal places. So I am confused on how to solve this problem. any solution, or recommendation would be highly appreciated.

1

There are 1 best solutions below

0
On

The easiest ways are sometimes the best ones...

You can add the resting to the first installment.

r=((700.00*100)%12)/100; //=00.04
installment[0]+=r;       //=58.37

I dont think that would be a big problem - the resting for 12 months would be at most $0.11\$$.