A Simple Car Loan Payment Calculator


#1

i feel my coding is right but my answer is 227 ! original answer is 233 . pls check and solve my problem

public class CarLoan {
public static void main(String[] args) {
int carLoan=10000;
int loanLength=3;
int interesRate = 5;
int downPayment = 2000;

if ( loanLength <= 0 || interesRate <= 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 * interesRate) /100;
  int monthlyPayment = monthlyBalance + interesRate;
  System.out.println( monthlyPayment);
}

}

}


#2

Add prints in your code to follow along in the logic, see where it goes wrong.


#3

i can`t get you ! pls explain clearly !


#4

Make your code explain to you what it is doing, read that output and compare to how you would do it manually.

System.out.println("I'm about to add 1 + 1");
int result = 1 + 1;
System.out.println("The result was: " + result);

#5

On step 14.
Calculate the final monthly payment. Create an int variable called monthlyPayment and set it equal to the monthly balance plus the interest.

You put 'interestRate" instead of "interest" Try this and you'll get 233.

-Mike G.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.