Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- 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 make a valid car loan (loan length and interest rate a positive number");
- }else if (downPayment >= carLoan){
- System.out.println("No loan required, the car can be paid for 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);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement