title: NaN error in quadratic formula calculator java
body: <p>I am working on a function for the quadratic formula in java eclipse mars, and when I compile the code it outputs NaN when mathematically this answer is possible and i should get 2.0 please help</p>
  
  <pre><code>import java.util.Scanner;
  public class Quadradic1 {
      public static void main(String[] args) {    
          double a;
          double b;
          double c;
          double x;
          System.out.print("Input A B C: ");
          Scanner input = new Scanner(System.in);
          a = input.nextDouble();
          b = input.nextDouble();
          c = input.nextDouble();
          x = (-b + Math.sqrt(b * b + 4 * a * c))/(2 * a);
          System.out.println("Quadratic1 " + x);
      }
  }
  </code></pre>
  
  <p>Sorry the values I entered are a=1 b=2 and c=-8</p>