/** * Manipulate and calculate roots of a quadratic equation, ax^2 + bx + c = 0. * * @author Devin Gray / class * @version February 8th 2016 */ public class QuadraticEquation { private double a; private double b; private double c; private double root1; private double root2; public QuadraticEquation(double newA, double newB, double newC) { a = newA; b = newB; c = newC; } public void solve() { //this method will calculate the roots double discriminant = Math.sqrt(b * b - 4 * a * c); root1 = (-b + discriminant) / (2 * a); root2 = (-b - discriminant) / (2 * a); } public double getRoot1() { return root1; } public double getRoot2() { return root2; } }