title: Why do I keep getting NaN as my output?
body: <p>I have created a loan payment calculator. Whenever I type in any input the output shows up as NaN. Any ideas to what I could change. The first section of code is the main method. The second is another class.</p>
  
  <p>MAIN METHOD</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Assignment8 {
  
      public static void main(String[] args) {
  
          Scanner kbd = new Scanner(System.in);
  
          System.out.print("Enter the amount borrowed: ");
          double amountBorrowed = kbd.nextDouble();
  
          System.out.print("Enter the interest rate: ");
          int intRate = kbd.nextInt();
  
          System.out.print("Enter the minimum length of loan: ");
          int minLength = kbd.nextInt();
  
          System.out.print("Enter the maximum length of loan: ");
          int loanLength = kbd.nextInt();
          while (loanLength &lt; minLength) {
              System.out.println("Invalid input: Input must be greater than minimum length of loan");
              System.out.println("Enter the maximum length of loan: ");
              loanLength = kbd.nextInt();
          }
  
          for (int i = minLength; i &lt;= loanLength; i++) {
              double payment = LoanCalc.monthlyPayment(amountBorrowed,loanLength, intRate);
              System.out.println(payment);
          }
  
      }
  
  }
  </code></pre>
  
  <p>CLASS</p>
  
  <pre><code>public class LoanCalc {
      public static double monthlyPayment(double amountBorrowed, int loanLength, int intRate) {
  
          double interestRate;
          double monthlyPayment;
  
          interestRate = intRate / 100 / 12;
  
          monthlyPayment = (interestRate * amountBorrowed) / (1- Math.pow((1 + interestRate) , - loanLength * 12 ));
  
          return monthlyPayment;
      }
  
  }
  </code></pre>