Hi, I'm writing a program that displays the balance of a loan after the first three monthly payments given the monthly payment, annual interest rate, and number of payments. I'm running into a problem calculating the interest rate per month. For example when I enter 0.09 for the annual interest rate my program prints 0.01 instead of 0.0075. The rest of my program seems to be working fine when printing out the balance after the first three payments. The function to calculate the interest rate per month is i = (rate / 12.0); which should return a double. Any help at all would be great. Thanks.
I found a possible reason for why my program is printing 0.01 instead of 0.0075.
When I deleted
cout << showpoint << fixed;
My program printed 0.0075, but of course my other outputs were shown in scientific notation. So if someone could point me in the direction to print out my outputs not in scientific notation while keeping my "i" value untouched that would be great.
Before:
Enter payment amount: 165.35
Enter interest rate (9% as 0.09): 0.09
Enter number of payments: 36
Payment entered was: $165.35
Interest rate is 0.09 which is 0.01 per month
Number of payments is 36
Payment #1 leaves a balance of $5073.38
Payment #2 leaves a balance of $4946.08
Payment #3 leaves a balance of $4817.82
After:
Enter payment amount: 165.35
Enter interest rate (9% as 0.09): 0.09
Enter number of payments: 36
Payment entered was: $1.7e+02
Interest rate is 0.09 which is 0.0075 per month
Number of payments is 36
Payment #1 leaves a balance of $5.1e+03
Payment #2 leaves a balance of $4.9e+03
Payment #3 leaves a balance of $4.8e+03