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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started