Android examples for java.lang:Math Formula
Formula to calculate quadratic
import java.text.DecimalFormat; public class Main{ private static double[] results = new double[2]; public static double[] quadratic(double a, double b, double c) throws InvalidInputException { if (((b * b - (4 * a * c)) < 0) == false) { results[0] = (-b + (Math.sqrt(b * b - (4 * a * c)))) / (2 * a); results[1] = (-b - (Math.sqrt(b * b - (4 * a * c)))) / (2 * a); return results; } else {// ww w .j a v a 2 s . com throw new InvalidInputException(); } } }