/** * @author John Paxton * @version 1.0 */ public class Javadoc { /** * Calculates the two roots of a quadratic equation, denoted by * ax^2 + bx + c = 0 and then determines the larger one. * * @param a the coefficient of the x^2 term * @param b the coefficient of the x term * @param c the coefficient of the constant term * * @return the larger of the two quadratic roots * @throws Exception if either the discriminant is negative or a is 0 */ public double largerRoot (double a, double b, double c) throws Exception { double discriminant; double root1; double root2; discriminant = Math.sqrt ( b * b - 4 * a * c ); if ((discriminant < 0) || (a == 0)) { throw (new Exception("Math Error")); } root1 = (-b + discriminant) / (2 * a); root2 = (-b - discriminant) / (2 * a); return Math.max(root1, root2); } }