/******************************************************************************
Replicated By LurkerSpace
:suskayge:
05/28/2022
*******************************************************************************/
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
double a, b, c;
double x1, x2;
System.out.println("Enter the value of a: "); //Ingresa el valor de A:
a = sc.nextDouble();
System.out.println("Enter the value of b: "); //Ingresa el valor de B:
b = sc.nextDouble();
System.out.println("Enter the value of c: "); //Ingresa el valor de C:
c = sc.nextDouble();
try {
if(b == 0){ //If square root B is 0, then Throw error
throw new Exception();
}
else {
x1 = ((-b) - (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a;
x2 = ((-b) + (Math.sqrt(Math.pow(b, 2) - 4 * a * c))) / 2 * a;
System.out.println("x1: " + x1 + ", x2: " + x2);
}
} catch (Exception e) {
System.out.println("There is A Problem"); //Hay un problema
}
}
}