/* Author: Seth Riedel
 * Purpose: Do the quadratic formula really fast
 * Version 1.5 (removes badly implemented imaginary answer handling)
 * Get newest version at http://github.com/brovie96/quadratic-formula
 */
import java.util.Scanner; //import scanner
public class QuadraticFormula
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner(System.in); //create scanner
      //define variables
      double a;
      double b;
      double c;
      double discrim;
      double firstAnswer;
      double secondAnswer;
      //get input
      System.out.print("Enter a value for a: ");
      a = input.nextDouble();
      System.out.print("Enter a value for b: ");
      b = input.nextDouble();
      System.out.print("Enter a value for c: ");
      c = input.nextDouble();
      //calculations
      discrim = Math.sqrt(Math.pow(b,2) - 4*a*c);
      firstAnswer = (-b + discrim)/(2*a);
      secondAnswer = (-b - discrim)/(2*a);
      //print result
      if (firstAnswer == secondAnswer) System.out.printf("The answer is %f.%n",firstAnswer);
      else if (Double.isNaN(discrim)) System.out.println("There are no real answers.");
      else System.out.printf("The answers are %f and %f.%n",firstAnswer,secondAnswer);
   } //end main method
} //end class
@@ -84,36 +84,22 @@
 n 1.
-5 (removes badly implemented
+6 (adds better
  ima
@@ -116,17 +116,16 @@
 wer hand
-l
 ing)%0D%0A *
@@ -540,24 +540,112 @@
 ondAnswer;%0D%0A
+      double discrimAginary;%0D%0A      double answerIReal;%0D%0A      double answerIMaginary;%0D%0A
       //get 
@@ -1050,24 +1050,161 @@
 im)/(2*a);%0D%0A
+      discrimAginary = Math.sqrt(-(Math.pow(b,2)-4*a*c));%0D%0A      answerIReal = -b/(2*a);%0D%0A      answerIMaginary = discrimAginary/(2*a);%0D%0A
       //prin
@@ -1344,16 +1344,35 @@
 iscrim))
+%0D%0A      %7B%0D%0A        
  System.
@@ -1384,41 +1384,86 @@
 rint
-ln
+f
 (%22The
-re are no real 
+ answers are %25f  %25fi.%25n%22,answerIReal,
 answer
-s.%22);
+IMaginary);%0D%0A      %7D //end if
 %0D%0A  

Version 1.6