## Description

Objectives:

This project was designed to reinforce the concept of for, while, and do while statements from Chapter

5 of textbook. In this project the student 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

Description of problem:

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 (page 2) 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

� = �� 1 + � ‘

1 + � ‘ − 1

The balance at the end of month n is

� = 1 + � *� − 1 + � * − 1 �

�

Total interest paid at the end of month n is:

����������������� = �� − (� − �)

You need to use the pow function in Math class. Math class belong to java.lang package. You don’t need

to import it. Here is the java expression for calculating monthly payment c:

� = � ∗ � ∗ ���ℎ. ���(1 + �, �)/(���ℎ. ��� 1 + �, � − 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.

Extra Credit: (total 3 points)

1. You will get 1 point extra credit if you tried both for loop and while loop to print out the table.

Please remember to comment away one solution. Do NOT delete any solution so that I can see

you have tried both solution

2. You will get 1 extra credit if you use do while loop to allow user try another mortgage if they

choose to do so

3. You will get 1 extra credit if your table also print out how much is the principal payment and

how much is the interest payment in each month’s payment.

Submission:

Submit the YourProj05.java file via Blackboard link. The due date will be announced on Blackboard.