Programming Logic With Java - A Simple Car Loan Payment Calculator

PROGRAMMING LOGIC WITH JAVA

A Simple Car Loan Payment Calculator
soluations:
i solve it:

public class CarLoan {
public static void main(String args) {

  /* ilias ahmed codeacademy forum member */

  /* This program calculates a car loan for whoever wants one of those
   */

  int carLoan = 10000;
  int loanLength = 3;
  int interestRate = 5;
  int downPayment = 2000;

  if (loanLength <= 0 || interestRate <= 0) {
    System.out.println("Error! I see you don't want a 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);
  }

  }
}

Hello @iliasahmed, welcome to the forums! Do you have a question, or are you just sharing the code for feedback?


Please note, we try to discourage sharing of complete code without any explanation or context on these forums.