gvsu/cs621/proj3/AmortizedLoan.java
josh 8818779daf commented, calculating interests
git-svn-id: svn://anubis/gvsu@74 45c1a28c-8058-47b2-ae61-ca45b979098e
2008-03-21 20:48:42 +00:00

32 lines
837 B
Java

/**
* AmortizedLoan provides a concrete implementation of a Loan object.
*/
public class AmortizedLoan extends Loan
{
/**
* This constructor simply calls the contructor from the Loan class.
*/
public AmortizedLoan(String name, double rate, int years, double amount)
{
super(name, rate, years, amount);
}
/* Return the loan type as a string */
public String toString()
{
return "Full Amortized Loan";
}
/**
* Calculate the monthly payment for a AmortizedLoan
*/
public void calcMonthlyPayment()
{
double adjMonthlyRate = m_interestRate / 100.0 / 12.0;
double lengthInMonths = m_length * 12;
double n = Math.pow(1 + adjMonthlyRate, lengthInMonths);
m_monthlyPayment = (m_principal * adjMonthlyRate * n) / (n - 1);
}
}