Error Message Car Loan Project -- Variable Not allowed there


#1



https://www.codecademy.com/courses/learn-java/projects/loan-payment-calculator

CarLoan.java:15: error: variable declaration not allowed here
int remainingBalance = carLoan - downPayment;
^
1 error

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

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