carLoan.java


#1



need help

I don't understand what the problem is with my else if statement? https://www.codecademy.com/en/courses/learn-java/projects/loan-payment-calculator?user_id=586bc7d7836966fc96000024


public class CarLoan {
	public static void main(String[] args) {

	int carLoan = 10000;
    
    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);
    
    System.out.println(monthlyPayment);
  }

	}
}


#2

if (loanLength <= 0 || interestRate <= 0); // remove ;

never use ; after if condition


#3

Yes, that was it! Thank you.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.