Learn java, Carloan calculator


#1

Hello,

Pretty much I have no clue what I’m doing wrong with my java code, It keeps erroring out:

CarLoan.java:17: error: 'else' without 'if'
     else if (downPayment >= carLoan){
     ^
1 error

Here is my code:

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

	//CarLoan Interger value
    int carLoan = 10000;
    //loanLength Interger value
    int loanLength = 3;
    //interestRate Interger value
    int interestRate = 5;
    //downPayment Interger value
    int downPayment = 2000;

   if (loanLength <= 0 || interestRate <= 0 ) {
     //Checking if the loanlength makes sense and is valid
     System.out.println("Error! You must take out a valid car loan.");
     
     else if (downPayment >= carLoan){
       
     }
   
   }
  }
}

Thanks for your much needed help


#2

You never ended your if statement with brackets before starting your else if