/* Author: Seth Riedel
 * Purpose: Do the quadratic formula really fast
 * Version 1.1 (with input, partially handles imaginary answers)
 */
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(firstAnswer))
      {
         if (Double.isNaN(secondAnswer)) System.out.println("There are no real answers.");
         else System.out.printf("The only real answer is %f.%n",secondAnswer);
      } //end if
      else if (Double.isNaN(secondAnswer)) System.out.printf("The only real answer is %f.%n",firstAnswer);
      else System.out.printf("The answers are %f and %f.%n",firstAnswer,secondAnswer);
   } //end main method
} //end class
@@ -84,32 +84,17 @@
 n 1.
-1 (with input, partially
+2 (better
  han
@@ -118,16 +118,87 @@
 swers)%0D%0A
+ * Get newest version at http://github.com/brovie96/quadratic-formula%0D%0A
  */%0D%0Aimp
@@ -485,16 +485,46 @@
 scrim;%0D%0A
+      double discrimAginary;%0D%0A
       do
@@ -566,24 +566,81 @@
 ondAnswer;%0D%0A
+      double firstAnswerI;%0D%0A      double secondAnswerI;%0D%0A
       //get 
@@ -1045,24 +1045,192 @@
 im)/(2*a);%0D%0A
+      discrimAginary = Math.sqrt(-(Math.pow(b,2) - 4*a*c));%0D%0A      firstAnswerI = (-b + discrimAginary)/(4*a*c);%0D%0A      secondAnswerI = (-b - discrimAginary)/(4*a*c);%0D%0A
       //prin
@@ -1446,39 +1446,69 @@
 rint
-ln
+f
 (%22The
-re are no real answers.%22
+ answers are %25fi and %25fi.%25n%22,firstAnswerI,secondAnswerI
 );%0D%0A
@@ -1548,34 +1548,47 @@
 The 
-only real answer is %25f.%25n%22
+answers are %25fi and %25f.%25n%22,firstAnswerI
 ,sec
@@ -1688,30 +1688,30 @@
 The 
-only real answer is %25f
+answers are %25f and %25fi
 .%25n%22
@@ -1714,32 +1714,46 @@
 .%25n%22,firstAnswer
+,secondAnswerI
 );%0D%0A      else S

Version 1.2