View Code of Problem 42

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        double x1 = (-b + Math.sqrt(b * b - 4 * a * c)) / 2 * a;
        double x2 = (-b - Math.sqrt(b * b - 4 * a * c)) / 2 * a;
        System.out.println(String.format("%.2f %.2f", x1, x2));
//        System.out.printf("%.2f %.2f\n",x1,x2);
//        System.out.println(String.format("%.2f",x1)+" "+String.format("%.2f",x2));
    }
}

Double click to view unformatted code.


Back to problem 42