Due: Wednesday, 24 February 1999
Most people purchase homes by securing a mortgage from a bank, mortgage company, or other lending institution. A mortgage is essentially a loan that is paid back over a number of years. In the United States, mortgages are typically 15 or 30 years in duration, and a fixed payment is made each month. Therefore, 180 payments are needed to repay a 15 year mortgage and 360 payments are needed to repay a 30 year mortgage. When one qualifies for a mortgage, the bank or mortgage company provides what is called an amortization schedule for the mortgage. An amortization schedule shows how much one must pay each month (fixed), how much interest is being charged for each month, and finally how much remains on the loan to pay off the mortgage.
Your task in this assignment is to generate an amortization schedule for a given mortgage amount and a given interest rate to be repaid over a period of n years. To explain how an amortization schedule is generated, suppose that Albertine wishes to purchase a cottage for the price of $120,000 and that she has saved $20,000 in cash for a down payment. Therefore, to pay the remainder of the purchase price, Albertine secures a 15 year mortgage in the amount of $100,000. She obtains an interest rate of 7.3% from the lender. Her monthly payment, M, is given by the formula:
M = P*r / [1 - (1+r)-12*N ].
The variable P (called the principal) is the initial loan amount, r is the monthly interest rate expressed in decimal form (e.g., 6% yearly rate of interest implies a monthly rate of 6/12 = 0.5%; so r = 0.005), and N is the length of the mortgage in years. For Albertine, the monthly payment is:
M = (100,000)*(0.006083) / [1 - (1.006083)-180 ] = 915.68.
(Here the monthly interest rate is 7.3/12 %. Thus r = 7.3/1200 = 0.006083.) Hence Albertine's monthly payment is $915.68, and this amount remains fixed throughout the life of the loan.
As the loan is paid off, the interest one pays is also reduced. To compute the interest for a particular month, suppose that B denotes the principal that is left to pay (i.e., B represents the balance of the loan). This is the amount of money still owed to the lender. The interest to be paid for that month is r*B. Consequently, what one actually pays back on the loan is M- r*B. Hence, after making this month's payment, the new value of B, call it Bnew, is given by the formula:
Bnew = B - (M - r*B) = B - M + r*B = B*(1+r) - M.
So the new balance (or, the updated principal) is given by B*(1+r) - M, and this is the balance of the loan that is used to compute the next month's interest and balance, etc.
Your program: Design and run a Java program that accepts
three numbers (amount borrowed, interest rate (in percent), and number
of years of loan) and prints an amortization schedule on a yearly basis
(not monthly). In addition, your program must print the total
interest paid during the life of the loan, and the monthly payment.
Notes:
1. Use \t (for tab)
to obtain proper alignment of columns.
2. Your program should consist of two classes: the class
Amortization
containing the main method, and the class Calculate
which provides several static methods. The static methods must
include
the following:
public static void printDollars(double amount)
// to print amount
in dollar & cents format; cursor does not advance to next line.
public static double monthlyPayment(double principal,
double interestRate, integer years)
// returns the (fixed)
monthly payment of the loan
// interest rate is
yearly rate (in percent)
public static double newBalanceMonth (double oldBalance,
double interestRate, double monthlyPayment)
// returns the new amount
owed to the bank after one month's payment
// interest rate is
yearly rate (in percent)
public static double newBalanceYear (double oldBalance,
double interestRate, double monthlyPayment)
// returns the new amount
owed to the bank after one year (i.e. 12 payments)
// interest rate is
yearly rate (in percent)
// this method calls
the newBalanceMonth method 12 times.
public static double yearlyInterest ( double balance,
double interestRate, double monthlyPayment)
// returns the total interest
paid in one year (i.e., 12 payments)
// interest rate is yearly
rate (in percent)
// the total interest paid
in one year = 12*M - change in balance owed (over 12 months)
3. To check your answers, there are numerous mortgage calculators available on the web. One of them is at http://www.interest.com/hugh/calc/mort.html.
Sample input/output:
Welcome to Dorian Gray's
Amortization program!
To begin, please input
the initial principal of the loan: 100000.00
Next, input the interest
rate (in percent per year): 7.3
Now, input the length
of the loan in years: 15
Thank you. Here
is the amortization schedule:
YEARS | YEARLY INTEREST | REMAINING PRINCIPAL |
1 | $7174.06 | $96185.86 |
2 | $6886.12 | $92083.78 |
3 | $6576.45 | $87672.02 |
4 | etc. | etc. |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
* | * | * |
14 | $1164.08 | $10565.77 |
15 | $422.43 | $0.00 |
Thank you for using Dorian's
program. Press enter to terminate this session.
What to submit:
All of the following should be contained in a two-pocket folder with your name, "Comp 170", and "day"/"evening" designation in large letters on the outside of the folder.
- Shakespeare, Hamlet