The monthly payment on a loan may be calculated by following formula:
Payment = Rate * (1+rate)^n/((1+Rate)^n-1)
Rate is the monthly interest rate, which is the annual interest rate divided by 12.(12% annual interest would be 1 percent monthly interest.) n is the number of payments and L is the amount of loan.
Write a program that asks for these values and displays a report similar to:
Loan amount: $10000.00
Monthly interest rate: 1%
Number of payments: 36
Monthly Payment: $332.14
Amount paid back: $11957.15
Interest paid: $1957.15
my out put comes out
Loan amount: :10000.00
Monthly interest rate:0.08
Number of payments: 36
Monthly Payment: $882.81
Amount paid back: $31781.29
Interest paid: $21871.29
as you can see my out put is wrong because it should comes out like the top one. interest rate is 1% but it shows 0.08%
I dont know why!
.08% looks like you divided 1%/12 rather than 12%/12. I would investigate whether your rate input is coming in as 1 rather than 12.
A suggestion: Don't reuse the value rate. Store annual rate in a separate variable from monthly rate. Then, for the time being, print out both.
Also, when you post code, please place it inside code tags. Click the "<>" button in the Format options and paste your code inside.
Also, your output doesn't match your code. According to your code, the Loan amount should have a "$" in front of it, but your output does not. Please copy and paste rather than re-typing your output, if possible.