Share
Explore BrainMass

Mortgage Calculator

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%. Must have strings to declare the variables.
_________________________________________________________________________

{
public static int defaultYears = 30;
public static float defaultLoanAmount = 200000;
public static float defaultInterestRate = 0.0575;

private int Years;
private float LoanAmount;
private float InterestRate;
private float MonthlyPayment;

public MortgageCalculator(){
Years = defaultYears;
LoanAmount = defaultLoanAmount;
InterestRate = defaultInterestRate;
}

public MortgageCalculator(int years, float LA, float IR){
Years = years;
LoanAmount = LA;
InterestRate = IR;
}

public int GetYears(){
return Years;
}
public void SetYears(int Years){
this.Years = Years;
}

public float GetLoanAmount(){
return LoanAmount;
}
public void SetLoanAmount(float LoanAmount){
this.LoanAmount = LoanAmount;
}

public float GetInterestRate(){
return InterestRate;
}
public float SetInterestRate(float InterestRate){
this.InterestRate = InterestRate;
}

public float GetMonthlyPayment(){
return MonthlyPayment;
}

//using the equation to calculate the monthly payment
Public void CalcMonthlyPayment(){
MonthlyPayment =
LoanAmount * (InterestRate / (1 - (InterestRate + 1) - 12 * Years)
}

//To convert a float value into a string,
public string ToString (float value){
return Float.toString(value);
}

//display the monthly payment, since the actually display is related to the UI //design which isn't required here, so this function only convert the //MonthlyPayment from numeric format to a string.
public string DisplayMonthlyPayment(){
return ToString(MonthlyPayment);
}
}
_________________________________________________________________________
How do I fix these errors?
init:

deps-jar:

Created dir: C:Documents and SettingsJason MollettJavaApplication3buildclasses

Compiling 1 source file to C:Documents and SettingsJason MollettJavaApplication3buildclasses

C:Documents and SettingsJason MollettJavaApplication3srcjavaapplication3Main.java:1: 'class' or 'interface' expected

{

C:Documents and SettingsJason MollettJavaApplication3srcjavaapplication3Main.java:51: illegal character: 8211

LoanAmount * (InterestRate / (1 - (InterestRate + 1) - 12 * Years)

C:Documents and SettingsJason MollettJavaApplication3srcjavaapplication3Main.java:51: illegal character: 8211

LoanAmount * (InterestRate / (1 - (InterestRate + 1) - 12 * Years)

3 errors

BUILD FAILED (total time: 0 seconds)

Solution Preview

/*
* MortgageCalculator.java
*
*/

public class MortgageCalculator {
public static int defaultYears = 30;
public static float defaultLoanAmount = 200000;
public static float defaultInterestRate = (float)0.0575;

private int Years;
private float LoanAmount;
private float InterestRate;
private float MonthlyPayment;

/** Creates a new instance of MortgageCalculator */

public MortgageCalculator(int years, float LA, ...

$2.19