I am trying to write a payment calculator program, but am receiving "NaN" as my result. The program asks for input on the loan amount and length of loan (in months). The program should then calculate out the monthly payments for each APR (3% -10%). I'm not sure if I have done something wrong with my calculation.
double L, payment;
double APR = 0;
int n;
Scanner input = new Scanner(System.in);
System.out.println("Loan calculator");
System.out.print("Enter the loan amount: ");
L = input.nextDouble();
System.out.print("Enter the number of payments: ");
n = input.nextInt();
double t = APR/1200.0;
for (APR = 3; APR <= 10; APR += .25){
payment = L * (t * (Math.pow((1.0 + t), n)) / (Math.pow((1.0 + t), n) - 1.0));
System.out.println(APR + "\t" + payment);