class QuadraticSolver {
    public static double solveQuadratic(double a, double b, double c)
    {
        double D = b * b - 4 * a * c;
        if (D < 0)
            throw new RuntimeException(); // complex solution
 
        return (-b + Math.sqrt(D)) / (2 * a);
    }
    
    public static void main(String[] args)
    {
        System.out.println("x ^ 2 - 5x + 2 = 0");
        System.out.println("x = " + QuadraticSolver.solveQuadratic(1, -5, 2));
    }
}
