How to force Java to throw arithmetic exception on dividing by 0.0 or extracting root from negative double? Code follows:
double a = 1; // or a = 0 to test division by 0
double b = 2;
double c = 100;
double d = b*b - 4*a*c;
double x1 = (-b - Math.sqrt(d)) / 2 / a;
double x2 = (-b + Math.sqrt(d)) / 2 / a;