// P.36 import java.util.Scanner; class Equation { public static void main(String[] args) { Scanner input = new Scanner(System.in); double a, b, c; double x, y, disc; System.out.print("Three coef: a b c - "); a = input.nextDouble(); while(a!=0) { b = input.nextDouble(); c = input.nextDouble(); disc = b*b - 4*a*c; if(disc>0) { x = (-b+Math.sqrt(disc))/(2*a); y = (-b-Math.sqrt(disc))/(2*a); System.out.println("Two roots: " + x + ", " + y); } else if(disc==0) { x = (-b-Math.sqrt(disc))/(2*a); System.out.println("One root: " + x); } else System.out.println("No real roots."); System.out.print("Three coef: a b c - "); a = input.nextDouble(); } System.out.println("\n\nDone.\n\n"); } }