-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarLoan.java
More file actions
32 lines (24 loc) · 811 Bytes
/
CarLoan.java
File metadata and controls
32 lines (24 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class CarLoan {
public static void main(String[] args) {
//a simple Car Loan calculator in Java..
int carLoan = 10000;
int loanLength = 3;
int interestRate = 5;
int downPayment = 2000;
int remainingBalance = carLoan - downPayment;
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 {
remainingBalance = (carLoan - downPayment);
}
int months = loanLength * 12;
int monthlyBalance = (remainingBalance / months);
int interet = (monthlyBalance * interestRate)/100;
int monthtlyPayment = monthlyBalance + interet;
System.out.println(monthtlyPayment);
}
}