-
-
Save codecademydev/f2f62be9cf68699ef7b76c063c8b02a9 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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