package mortgagecalculator; import java.util.*; /** mortgagecalculator.java * Created on June 27, 2004, 5:07 PM * Java Programming Project Workshop 2 – * Problem statement – Create a Mortgage Calculator WITHOUT a graphical user interface * Purpose – provide a user-friendly service to potential users for accurately planning mortgage and other types of loans * Scope – The mortgage calculator must display the mortgage payment amount given the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. This program must have hard code amount = 200,000, term= 30 years, and the interest rate = 5.75%. . * Algorithm – standard loan calculation with fixed number of payments: * Monthly Payment = Principal * (InterestRate / (1 – (InterestRate + 1) – 12 * Periods) will be used for next workshop project * * Inputs: * Principal = $200,000 * Interest Rate = 0.0575 * Periods = 360 * * Output: * Monthly Payment = $1167 * * @author TERRY PARKER POS 406 * NETBEANS IDE 3.6*/ public class Mortgagecalculator{ /** Creates a static mortgagecalculator */ public static int defaultYears = 30; public static double defaultLoanAmount = 200000; public static double defaultInterestRate = .0575; private int Years; private double LoanAmount; private double InterestRate; private double MonthlyPayment; public void MortgageCalculator(){ Years = defaultYears; LoanAmount = defaultLoanAmount; InterestRate = defaultInterestRate; } public void MortgageCalculator(int years, double LA, double IR){ Years = years; LoanAmount = LA; InterestRate = IR; } public int GetYears(){ return Years; } public void SetYears(int Years){ this.Years = Years; } public double GetLoanAmount(){ return LoanAmount; } public void SetLoanAmount(double LoanAmount){ this.LoanAmount = LoanAmount; } public double GetInterestRate(){ return InterestRate; } public void SetInterestRate(double InterestRate){ this.InterestRate = InterestRate; } public void CalcMonthlyPayment(){ MonthlyPayment = (LoanAmount * (1 + InterestRate) * LoanAmount * InterestRate) / ( (1 + InterestRate) * LoanAmount -1); } public String ToString (double value){ return Double.toString(value); } public String DisplayMonthlyPayment(){ return ToString(MonthlyPayment); } }