HW10 Quadratic Equations with Solution


Due Friday, December 13, 11: 59pm

Design a class named Quadratic for a quadratic equation ax2 + bx + c = 0.

The solution to the quadratic equation is given by this formula:

The class contains:

  • Private data fields a, b, and c that represent three coefficients.
  • A constructor with arguments for a, b, and c.
  • A method named noOfRoots() that returns the number of real roots for the quadratic, either 0, 1, or 2
  • Methods getRoot1() and getRoot2() that returns the roots. These methods are useful only if the noOfRoots is nonnegative.

Download this driver class to test your implementation: QuadraticDriver.java (Do Not Change the Driver at all.)