Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created December 26, 2018 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/f2f62be9cf68699ef7b76c063c8b02a9 to your computer and use it in GitHub Desktop.
Save codecademydev/f2f62be9cf68699ef7b76c063c8b02a9 to your computer and use it in GitHub Desktop.
Codecademy export
public class CarLoan {
public static void main(String[] args) {
int carLoan = 10000;
int loanLength = 3; // represente le nombre d annee
int interestRate = 5; //represente les interet
int downPayment = 2000;// c est un accompte
if(loanLenght <= 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;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment