title: Why Quadratic equation's root result is NaN ? (Java)
body: <p>Why write out 
  <strong>The roots are NaN and NaN</strong> in console?
  I've read about NaN, but I don't find the right solution how can I repair the mistakes...
  I've tried <strong>casting to double</strong> the <strong>discriminant</strong> and the <strong>roots</strong> but doesn't work.
  Can somebody help me, where and what I need to rewrite?</p>
  
  <pre><code>public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      Pattern newlineOrSpace = Pattern.compile(System
              .getProperty("line.separator")
              + "|\\s");
      sc.useDelimiter(newlineOrSpace);
      System.out.print("Enter a, b, c: ");
      double a = sc.nextDouble();
      double b = sc.nextDouble();
      double c = sc.nextDouble();
      // System.out.format("a = %f, b = %f, c = %f", a, b, c);
  
      double root1;
      double root2;
      double discriminant;
      discriminant = Math.sqrt(b * b - 4 * a * c);
      if (discriminant &gt; 0) {
          System.out.println("There are no real roots ");
      } else {
          root1 = (-b + discriminant) / (2 * a);
          root2 = (-b - discriminant) / (2 * a);
          System.out.println("The roots are " + root1 + " and " + root2);
      }
  </code></pre>