import java.util.Scanner; public class Main { public static void main(String[] args) { double a, b, c; Scanner sc = new Scanner(System.in); a = sc.nextDouble(); b = sc.nextDouble(); c = sc.nextDouble(); double x1 = ((-1 * b) + Math.sqrt(b *b - 4 * a * c)) / 2 * a; double x2 = ((-1 * b) - Math.sqrt(b *b - 4 * a * c)) / 2 * a; if(x1 > x2) { String format = String.format("%.2f %.2f", x1, x2); System.out.println(format); } else { String format = String.format("%.2f %.2f", x2, x1); System.out.println(format); } } } |
Double click to view unformatted code.