I am currently trying to calculate a monthly payment plan in C# given a loan amount, a rate, and a duration in years.
My professor provided a executable version of the assignment, but with no code.
Along with that he has given us the formula to calculate monthly payments:
To get the APR, the user entered the Percentage in a text box and I divided the number by 100 to get it in a decimal.
To get the Duration, the user entered the Years in a text box and I the multiplied the number by 12 to get it in months.
My C# code looks like this:
payment = (loanAmount*aprPercent) / (1-Math.Pow((1+aprPercent), -durationMonths));
I have triple checked to see that that code follows the formula my professor provided.
Yet when I use the exact same input in my professors executable as I do in my application the numbers are way off.
For Example:
I enter 12% APR, 12 Years Duration, and 12 Dollar LoanAmount on both mine and my professors application. His comes to a $0.16 monthly payment and mine comes to a $1.44 monthly payment.
Remember that I did devide 12%/100 to get a .12 for aprPercent. And multiplied 12*12 to get durationMonths. So I do not see why our outputs are way different.
Please note that this is not the extent of my assignment, this is just a part of the assignment that I need to figure out before I can finish the rest of the assignment. It is due friday of next week, so I did not procrastinate. I am not trying to use the people of StackOverflow to solve my homework for me, I am using them as a resource to help me solve my issue and will state this thread in the comments of my application.
You should be using the monthly percentage figure for the rate, not the yearly one. This is fairly evident since, at $1.44 a month, you’d pay off your loan in about nine months rather than twelve years 🙂
12% p.a. gives you a yearly
aprPercentof0.12but the monthly equivalent is0.12 / 12 = 0.01:Or sixteen cents, as your educator has told you.