Issues with formula.

closed account (G1pE3TCk)
Hey all, I'm pretty new to C++ so hang with me. I am writing a program to calculate a car loan repayment and I am having issues with what my equation is outputting versus what I should actually be getting. any help would be greatly appreciated.

here is the equation we should be using:

monthly payments= principal * r * (1+r)^n / ((1+r)^n - 1)

here is my code:

payment=(loanamount1*rate1*pow((1+rate1),ltmonths))/(pow((1+rate1),ltmonths)-1);

loanamount1=70000.00
ratel=4.2%=0.042
ltmonths="loan term in months"= it is a 5 year loan, so 5*12=60 months.

I should output a monthly payment of 1295.48. However, the program is outputting 3212.10.

is there something wrong with how I have my formula typed in C++?

Try double rate1 = 4.2/100 /12;
(convert annual to monthly rate)
Topic archived. No new replies allowed.