Question: This is JAVA Programming.. . This is designed to reinforce the concept of for, while, and do while statements. In this question you will practice:
This is JAVA Programming...
This is designed to reinforce the concept of for, while, and do while statements. In this question you will practice:
1. Using an for structure.
2. Replacing an for structure with a while statement.
3. Using do while to repeat things that at least be done one time
QUESTION:
Write a mortgage calculator program to calculate fixed rate mortgage payment. Your program should print out an amortization table on screen. For mortgage calculator and its related formula, please visit http://en.wikipedia.org/wiki/Mortgage_calculator
The program input will be Principle, Term (in year), Quoted Interest Rate. To simplify the program, the program output, i.e. your amortization table only need to contain the following four columns: Month, Payment, Total Interest, and Balance. Please see the attached screen shot for an input and output example.
Formula used: Suppose that P is the principle, N = term * 12, and r = (Quoted Interest Rate /12) in decimal (not percentage), then monthly payment c is
c= Pr(1+r)N / (1+r)N - 1
The balance at the end of month n is: b= (1+r)nP - ((1+r)n - 1)c / r
Total interest paid at the end of month n is: totalInterestPaid= cn - (P - b)
You need to use the pow function in Math class. Math class belong to java.lang package. You dont need to import it. Here is the java expression for calculating monthly payment c:
c= P * r * Math.pow(1 + r, N) / (Math.pow(1 + r, N) - 1)
Check Your Result:
Please see a sample run of the project at the end of this file. Please visit this website to check your result http://www.bankrate.com/calculators/mortgages/mortgage-calculator.aspx
You may use either for loop or while loop to finish printing amortization table.
SAMPLE:
ENTER THE PRINCIPLE TO BORROW: $50000
ENTER THE interestRate IN DECIMAL: 0.05
ENTER THE TERM (IN YEARS): 2
| MONTH | PAYMENT | TOTAL INTEREST | BALANCE |
| 1 | $ 2193.57 | $ 208.33 | $ 48014.76 |
| 2 | $ 2193.57 | $ 408.39 | $46021.26 |
| 3 | $ 2193.57 | $ 600.15 | $ 44019.44 |
| 4 | $ 2193.57 | $ 783.56 | $ 42009.29 |
| 5 | $ 2193.57 | $ 958.60 | $ 39990.76 |
| 6 | $ 2193.57 | $ 1125.23 | $ 37963.81 |
| 7 | $ 2193.57 | $ 1283.41 | $ 35928.43 |
| 8 | $ 2193.57 | $ 1433.12 | $ 33884.56 |
| 9 | $ 2193.57 | $ 1574.30 | $ 31832.18 |
| 10 | $ 2193.57 | $ 1706.94 | $ 29771.24 |
| 11 | $ 2193.57 | $ 1830.98 | $ 27701.72 |
| 12 | $ 2193.57 | $ 1946.41 | $ 25623.57 |
| 13 | $ 2193.57 | $ 2053.17 | $ 23536.77 |
| 14 | $ 2193.57 | $ 2151.24 | $ 21441.27 |
| 15 | $ 2193.57 | $ 2240.58 | $ 19337.04 |
| 16 | $ 2193.57 | $ 2321.15 | $ 17224.04 |
| 17 | $ 2193.57 | $ 2392.92 | $ 15102.24 |
| 18 | $ 2193.57 | $ 2455.84 | $ 12971.59 |
| 19 | $ 2193.57 | $ 2509.89 | $ 10832.07 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
