Suppose I have three parameters - Original Principal = 500, terms(in months) = 12, and Interest rate = 8.25. I want write a function that produce the following below. For that monthly payment, I can code it.
For example. P = 500, i = (8.25/100)/12, and n = 12 (months).
monthlypayment = P [(i(1 + i)^n / ((1 + i)^n) - 1]
43.55 = monthlypayment.
But what about Cumulative principal and cumulative interest rate? (Note: those aren't negative numbers, just - in front).
Month Total Principal Interest Cum Princ Cum Int
1 -$43.55 -$40.11 -$3.44 -$40.11 -$3.44
2 -$43.55 -$40.39 -$3.16 -$80.50 -$6.60
3 -$43.55 -$40.67 -$2.88 -$121.17 -$9.48
4 -$43.55 -$40.95 -$2.60 -$162.12 -$12.09
5 -$43.55 -$41.23 -$2.32 -$203.35 -$14.41
6 -$43.55 -$41.51 -$2.04 -$244.86 -$16.45
7 -$43.55 -$41.80 -$1.75 -$286.66 -$18.20
8 -$43.55 -$42.09 -$1.47 -$328.75 -$19.67
9 -$43.55 -$42.37 -$1.18 -$371.12 -$20.85
10 -$43.55 -$42.67 -$0.89 -$413.79 -$21.73
11 -$43.55 -$42.96 -$0.59 -$456.75 -$22.33
12 -$43.55 -$43.25 -$0.30 -$500.00 -$22.62
Above is an output from Excel, but I want to do the same in C++?