Here's how I learned simple intrest in high school:
A=P(1+i)
n
where:
A = amount at maturity
P = Principle invested
i = intrest rate (as a decimal)
n = compounding periods
so I must ask what this is:
double futurevalue = payment * pow(1 + rate / periods, - 1 / periods);
note: Use code tags please
What you have is:
A = P(1+i/n)
-1/n
or something along those lines.
Simply create an extra variable (bad practice, but it's a small program)
double i;
, define it as
i = 1 + (i/100);
and in the parameters for pow, use
pow (i, periods);
It works, from your code, here's what I got:
Enter payment amount: 1000
Enter an interest rate: 4
Enter number of payment periods: 5
Your future value is: 889.09
|
from my edits:
Enter payment amount: 1000
Enter an interest rate: 4
Enter number of payment periods: 5
Your future value is: 1216.65
|
The final proper value, if
you I do the math:
A = P(1+i)
n
A=?
P=1000
i=(4/100)
n=5
A = 1000(1+0.04)
5
A = 1000(1.04)
5
A = 1000(1.216652902)
A = 1216.652902
Therefore, the amount at maturity will be $1216.65.