I have a assignment and I cant figure out why the payment value cannot be resolved.. Can anyone help?
import java.util.*;
public class HW8 {
public static double payment(double amnt, double intrate, int mths){
double mnthpymnt;
mnthpymnt= amnt*((intrate)*(Math.pow((1+intrate),mths))/(Math.pow((1+intrate),mths)-1));
return payment;
}
public static double balance2(double balance, double intrate, double mnthpymnt ){
double pramnt, intamnt, endbal;
intamnt= intrate*balance;
pramnt=mnthpymnt-intamnt;
endbal= balance-pramnt;
System.out.printf("The interest is $%.2f and the principle is $%.2f %n", intamnt, pramnt);
return endbal;}
public static void main ( String[]args){
Scanner hw=new Scanner(System.in);
int index;
double mnthamnt, endbal;
System.out.println("What is the amount of the loan?");
double amnt= hw.nextDouble();
System.out.println("What is the interst rate?");
double intrate=hw.nextDouble();
System.out.println("What is the yearly loan period?");
int mths=hw.nextInt();
System.out.printf("The amount of the loan is $%.2f%n", amnt);
System.out.printf("The interest percentage on the loan is %.1f %n", intrate);
mths=mths*12;
System.out.printf("The duration of the loan in years is %n", mths);
intrate=(.01*intrate)/12;
mnthamnt= payment(amnt,intrate, mths);
System.out.printf("The monthly payment is $%.2f %n", mnthamnt);
endbal= amnt;
for(index=0; index<mths; index= index+1)
endbal=balance2(endbal,intrate,mnthamnt);}
}