Hi everyone! I'm creating a class for a mortgage payment. I pretty much have most of the code finished but when I compile the code I receive multiple errors saying "Cannot find symbol". This error occurs about 9 times and I am also having some problems with the compareTo method. If anyone can help me that would be greatly appreciated.
Thanks in advance.
Here's the code:
import java.io.*;
import java.util.*;
import java.lang.*;
public class Loan implements Comparable<Loan>
{
private double borrowed;
private double interestRate;
private int years;
public Loan()
{
borrowed = 0;
interestRate = 0;
years = 0;
}
public Loan(double tborrowed, double interestR, int tyears)
{
this();
borrowed = tborrowed;
interest = interestR;
years = tyears;
}
public void setBorrowed(double tborrowed)
{ borrowed = tborrowed; }
public double getBorrowed()
{ return borrowed; }
public void setInterest(double interestR)
{ interest = interestR; }
public double getInterest()
{ return interest; }
public void setYears(int tyears)
{ years = tyears; }
public int getYears()
{ return years; }
public double monthlyPayment()
{
double N = years * -12;
double R = interest * 0.01;
R = R/12;
double monthlypayment = (amount * R) / (1 - (Math.pow(1 + R, N)));
return monthlypayment;
}
public double totalPayment()
{
double totalPayment = 0;
int months = years * 12;
for (int i = 0; i <= months; i++)
{
totalPayment += Loan.monthlyPayment;
}
return totalPayment;
}
public double totalInterest()
{
double totalInterest = Loan.totalPayment - borrowed;
return totalInterest;
}
public String toString()
{ return borrowed + " " + Loan.monthlyPayment;}
public int compareTo(Loan otherLoan)
{
return borrowed.compareTo(otherLoan.borrowed);
}
}