Write a Java program without a graphical user interface that calculates and displays the monthly mortgage payment amount, given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage.
· In this program, hard code the amount as $200,000, the term as 30 years, and the interest rate as 5.75%. Insert comments in the program to document the program.
· Insert version control information in the program (Author, Modified Date, version, description).
Then this was added.
Looks like there is some confusion on how to go about doing the calculation... First take a look at the formula and break it down into meaningful steps. There are three inputs to the formula.
a) Principal
b) Annual Interest
c) Loan years.
Here is the formula: M = P * (J/ (1-(1+J)^ - N)). The following website does a wonderful job in dissecting the above formula. http://www.hughchou.org/calc/formula.html
Here,
M = Mortgage Payment
P = principal
J = monthly interest
N = Number of Months for loan.
We already know P, J, N now we need to plug that in, in the formula. First lets take the denominator
double denominator = Math.pow( 1 + monthlyInterest, -360); // this is the (1+J)^ - N
well almost done, but still there is this (1 - (1+ J)^ - N)... so, denominator = 1 - denominator;
Now, the easy part, (top half) P * (J/denomiator))
double monthlyPayment = principal * (monthlyInterest/denominator);
I am so confused. I do not even know where to start. Please help.