Need help


#1

im getting the wrong answer
public class CarLoan {
public static void main(String[] args) {
int carLoan = 10000;
int loanLength = 3;
int interestRate = 5;
int downpayment = 200;
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 + interestRate;
System.out.println( monthlyPayment);
}



}

}


#2

@netmaster89815,
Maybe it is better to use =float= instead of =int= as data-type....
and maybe you will then need
http://stackoverflow.com/questions/5195837/format-float-to-n-decimal-places
and/or
http://stackoverflow.com/questions/4377842/how-can-i-convert-integer-into-float-in-java
http://stackoverflow.com/questions/1295424/how-to-convert-float-to-int-with-java


#3

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