View Code of Problem 42


import java.util.Scanner;

public class Main {

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

Double click to view unformatted code.


Back to problem 42