Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Please enter downPayment");
- int downPayment = input.nextInt();
- //amount of money
- int carLoan = 10000;
- //years
- int loanLength = 3;
- int interestRate = 5;
- 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{
- 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