The course of A Simple Car Loan Payment Calculator

In the course A Simple Car Loan Payment Calculator

My code looks like this

public class CarLoan {
int carLoan;
int loanLength;
int interestRate;
int downPayment;

CarLoan(int a, int b, int c, int d) {
carLoan = a;
loanLength = b;
interestRate = c;
downPayment = d;
}

void cheakLoan() {
if (loanLength <= 0 || interestRate <= 0) {
System.out.println(“Error! You must take out a valid car loan.”);
} else if (downPayment >= carLoan) {
System.out.println(“The car can be paid in full.”);
} else {
int remainingBalance = carLoan - downPayment;
int months = loanLength * 12;
int monthlyBalance = remainingBalance / months;
int interest = monthlyBalance * interestRate / 100;
int monthlyPayment = monthlyBalance + interest;
System.out.println(monthlyPayment);
}
}

public static void main(String args) {
CarLoan paymentPlan = new CarLoan(10000,3,5,2000);
paymentPlan.cheakLoan();
}
}

After running, many errors are displayed. Although the code is written according to the tutorial, I still don’t understand why my method reports an error.

That code above seems to run fine for me.

code for CarLoan.java (copied from post)
public class CarLoan {
  int carLoan;
  int loanLength;
  int interestRate;
  int downPayment;

  CarLoan(int a, int b, int c, int d) {
    carLoan = a;
    loanLength = b;
    interestRate = c;
    downPayment = d;
  }

  void cheakLoan() {
    if (loanLength <= 0 || interestRate <= 0) {
      System.out.println("Error! You must take out a valid car loan.");
    } else if (downPayment >= carLoan) {
      System.out.println("The car can be paid in full.");
    } else {
      int remainingBalance = carLoan - downPayment;
      int months = loanLength * 12;
      int monthlyBalance = remainingBalance / months;
      int interest = monthlyBalance * interestRate / 100;
      int monthlyPayment = monthlyBalance + interest;
      System.out.println(monthlyPayment);
    }
  }

  public static void main(String[] args) {
    CarLoan paymentPlan = new CarLoan(10000,3,5,2000);
    paymentPlan.cheakLoan();
  }
}

Thank you, my friend ran it and said no problem, maybe there is a problem with the java compiler on the website, or it is better to use ide to run the code.

may I ask that is the “void checkLoan” necessary?
first I don’t type the void, so the code is error.
and I add it in, it’ll be successed.

I don’t think that method is necessary.
You could do that in a different method, or in the main method.

You mean the if-then sentens moving to the main method?
Doesn’t it get error?

you can move more of the stuff to the main method,
then there would not be an error (depending on what you move).