Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CarLoan {
- public static void main(String[] args) {
- //this program calculate the monthly payment a perosn would pay for a car loan
- int carLoan = 10000;
- int loanLength = 3;
- int interstRate = 5;
- int downPayment = 2000;
- int remainingBalance = (carLoan - downPayment);
- int months = (loanLength * 12);
- int monthlyBalance = (remainingBalance / months);
- int interest = (monthlyBalance * interstRate) / 100;
- int monthlyPayment = (monthlyBalance + interest);
- {
- if (loanLength <= 0 || interstRate <= 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
- System.out.println(monthlyPayment);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement