Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public class CarLoan {
  2. public static void main(String[] args) {
  3. //this program calculate the monthly payment a perosn would pay for a car loan
  4. int carLoan = 10000;
  5. int loanLength = 3;
  6. int interstRate = 5;
  7. int downPayment = 2000;
  8. int remainingBalance = (carLoan - downPayment);
  9. int months = (loanLength * 12);
  10. int monthlyBalance = (remainingBalance / months);
  11. int interest = (monthlyBalance * interstRate) / 100;
  12. int monthlyPayment = (monthlyBalance + interest);
  13. {
  14. if (loanLength <= 0 || interstRate <= 0)
  15. System.out.println("Error! You must take out a valid car loan.");
  16.  
  17. else if (downPayment >= carLoan)
  18. System.out.println("The car can be paid in full.");
  19.  
  20. else
  21. System.out.println(monthlyPayment);
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement