Assignment #2 CSI205 Assigned 09/20/11
Due 09/29/11
Assignment:
Create a class that can be used by clients
to perform mortgage calculations.
Specifically,
your class will be used to calculate mortgage payment, total interest
charge, and future value of a mortgage based on the
amount of the loan (Principal),
interest rate, and term.
The Mortgage
Payment is computed as:
Payment=(Principal*r/12.0)/(1-temp)
where
r =
interest rate/100.0
temp =
(1.0/pow(x,y))
x =
1.0+r/12.0
and y
= term of mortgage in years *
12.0
pow(x,y) is a method defined in the Math class that
raises x
to
the y power.
The Future Value
of the loan is computed as:
Future value = Payment * term of mortgage
in years * 12
The Interest
Charge is computed as:
Interest Charge = Future Value - Amount
of Loan
Your class should
contain the following:
Private Data
Fields:
double interestRate
double term
double principal
Public Methods:
//Constructor
Method. Accepts values for interest rate, term, and principal and places these
//values into the
corresponding private data fields
MortgageCalcs(double interestRate,
double term, double principal)
//this method
calculates and returns the Monthly Payment.
double calcPayment()
//this method
calculates and returns the Future Value.
double futureValue()
//this method
calculates and returns the Interest Charge.
double intCharge()
A sample client
has been created that will allow you to test your implementation of MortgageCalcs.
To test
MortgageCalcs.java:
- copy the client
application, named TestMortgage.class, from the class
folder on the ITS Unix
system to your own folder. The client is located in
/home2/classes/csi205/TestMortgage.class
- Compile your
MortgageCalcs.java
- Run TestMortgage and follow the on-screen instructions. TestMortgage will
create and use one of your MortgageCalcs
object.
Notes:
-Include Comments
in your code and format your program neatly. Remember to
include your name and
Student ID# in your comments
-All variables
you use for mathematical computations should be of type double
-You should only
submit MortgageCalcs.java. (the "M" and "C" are uppercase!)
-The turnin command for assignment #2 is
turnin-csi205 -c
csi205 -p prog2 MortgageCalcs.java