View Code of Problem 42

package com.test;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();


        double outpu1 = ((-1)*b+Math.sqrt(b*b - 4 * a * c))/2*a;

        double outpu2 = ((-1)*b-Math.sqrt(b*b - 4 * a * c))/2*a;

        String format = String.format("%.2f %.2f", outpu1, outpu2);
        System.out.println(format);
    }
}

Double click to view unformatted code.


Back to problem 42