Question: Write a class that implements a quadratic equation. As we all remember from our math classes of yesteryear, a quadratic equation comes in the following

Write a class that implements a quadratic equation. As we all remember from our math classes of yesteryear, a quadratic equation comes in the following form: [-b +/- sqrt(b^2 - 4ac)] / 2a So, here's what I want to see:

A private type, which can hold values for 'a' 'b' and 'c'.

A constructor method (call it "new" if you'd like)

A method for getting the discriminant (that's the (b^2 - 4ac) part)

A method for getting the positive quadratic (the '+' side of '+/-')

A method for getting the negative quadratic (the '-' side of '+/-')

If you can't evaluate the positive or negative quadratics because the discriminant is negative (meaning you would otherwise try to evaluate the square root of a negative number), throw a user-defined exception.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!