lol1234561

Untitled

Jan 26th, 2023
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner input = new Scanner(System.in);
  5.         System.out.println("Please enter downPayment");
  6.         int downPayment = input.nextInt();
  7. //amount of money
  8.         int carLoan = 10000;
  9.         //years
  10.         int loanLength = 3;
  11.         int interestRate = 5;
  12.  
  13.         if (loanLength <= 0 || interestRate <= 0){
  14.             System.out.println("Error! You must take out a valid car loan.");
  15.         } else if(downPayment >= carLoan){
  16.             System.out.println("the car can be paid in full");
  17.         }else{
  18.             int remainingBalance = carLoan - downPayment;
  19.             int months = loanLength * 12;
  20.             int monthlyBalance = remainingBalance/months;
  21.             int interest = monthlyBalance*interestRate/100;
  22.             int monthlyPayment = monthlyBalance + interest;
  23.             System.out.println(monthlyPayment);
  24.  
  25.         }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment