Java Car Loan Calculator

So I completed the exercise, but I got the wrong answer. It gave me “The car can be paid in full” instead of “233.”

I even looked at the walkthrough but it’s still messing up.

public class CarLoan {

  public static void main(String[] args) {

  int carLoan = 1000;

  int loanLength = 3;

  int interestRate = 5;

  int downPayment = 2000;

    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;




1 Like

Hello @arc3009184213 , welcome to the forums! Unfortunately, I don’t have PRO, so I can’t see the project. Could you tell me how the car loan is being calculated?

You’re statement “if (downPayment >= carLoan)” Will always evaluate as true because the downPayment is greater than or equal to the carLoan.

In Other words;

2000 >= 1000;

so it prints out the statement and doesn’t advance. Try changing the loan amount to a value greater than 2000.

1 Like

Hey @arc3009184213 , it’s been a little while since you originally posted this question. Could you come back to let us know if the above reply helped you?