how would you translate this formula to work in c++ and can u explain why you did what you did because I am new to this.
(p * (1 + r) n * r) / ((1 + r) n - 1)
this is what I tried so far. do I need to split it into two variables?
p is the amount borrowed
• r is the monthly decimal interest rate
• n is the number of monthly payments in the payback period
(amtBorrowed * (1 + rateInterest)) HERE payPeriod * rateInterest))
See where I've written HERE in that line? There's something missing there. I'm guessing you want that to multiply, so it should perhaps be: (amtBorrowed * (1 + rateInterest)) * payPeriod * rateInterest))
Likewise (1 + rateInterest) HERE payPeriod - 1)
Basically, just write it out much more explicitly.
if you were really uptight you could try to rearrange it to do less work, eg tmp = n+n*r and then (p*tmp*r)/(tmp -1)
but this is not saving enough computation to be worth a lot of over-thinking it. Alternately if the equation has a 'standard form' that people recognize, use that form.
the compiler is not recognizing the second part of the equation, (I've tried adding more parentheses but just the same error with different characters.)
n is "the number of monthly payments in the payback period".
If the payback period is 30 years, and you do monthly payments, that is 30 * 12 = 360 payments.
And your interest rate is the monthly interest rate. The assignment's wording isn't exactly being clear here, so I'll just say you need to divide by 12.