A Simple Car Loan Payment Calculator

PHOTO EMBED

Sat Sep 24 2022 22:46:06 GMT+0000 (Coordinated Universal Time)

Saved by @cruz #javascript

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);
  }

	}
}
content_copyCOPY

https://www.youtube.com/watch?v=HEkYvjlmyYI&ab_channel=Codecademy