import java.util.Scanner; public class Quadratic3 { public static void main (String[] Args) { System.out.println("Input the three coeficients"); Scanner getInput = new Scanner (System.in); double a = getInput.nextDouble(); double b = getInput.nextDouble(); double c = getInput.nextDouble(); if (a==0) if (b!=0) System.out.println("One real root: " + -c/b); else if (c==0) // note a and b are zero System.out.println("Trivial: all values are roots!"); else System.out.println("Inconsistant: no roots!"); else { // a!=0 double discriminant = b*b - 4*a*c; if (discriminant<0) System.out.println("The roots are complex."); else if (discriminant == 0) System.out.println("One (double) root: " + -b / (2*a)); else { // discriminant > 0 double ans1 = (-b + Math.pow(discriminant, .5))/ (2*a); double ans2 = (-b - Math.pow(discriminant, .5)) /(2*a); System.out.println ("Two roots: " + ans1 + " and " + ans2); } } } }