I know the financial formula for calculating compound interest:
Compound Interest Multiple = [1+(Annual Interest in decimals/365)]^(number of days).
I have a initial and final date. I calculate the difference between these two dates in days. Then i divide the total days for 90 (quarterly).
Quarter = (double) days / 90.0;
capitalAndInterest = capital * pow ((1.0 + rate/100.0/4.0), quarter);
Unfortunately that formula doesn't fit, cause i need to know at the end of each quarter what is the partial days' sum and the partial interest calculated.
Perhaps i should update capital compounded with the given rate at the end of every quarter ? ?
1) Take initial date and see in which quarter i'm in. If ie i'm in first quarter do a difference between initial date and the end of first quarter (31th march). Do the math calculation.
2) Do the same for final date.
3) Then calculate the exact quarters left
4) Cycle all these quarters and do the math calculation for each period (but how to cycle them ??)
5) Adding all these results in an array
but all that seems too complicated, perhaps there's another simpler approach to the solution ?