import java.util.Scanner; public class Abc4 { public static void main(String[] args) { double a, b, c, Det, re, im; Scanner in = new Scanner(System.in); // Construct Scanner object System.out.print("Enter a:"); a = in.nextDouble(); // Read in next number into a System.out.print("Enter b:"); b = in.nextDouble(); // Read in next number into b System.out.print("Enter c:"); c = in.nextDouble(); // Read in next number into c Det = b*b - 4*a*c; if ( Det >= 0 ) { System.out.println( (-b + Math.sqrt( Det ) ) / (2*a) ); System.out.println( (-b - Math.sqrt( Det ) ) / (2*a) ); } else { re = -b/(2*a); // Compute real part im = Math.sqrt( -Det )/(2*a); // Compute imaginary part System.out.println( re + "+" + im + "i" ); System.out.println( re + "-" + im + "i" ); } } }