Question: Make a QuadRoots.java program that ask the user for three numbers, a,b and c. coefficients of the quadratic. Try to use a loop and try...catch
Make a QuadRoots.java program that ask the user for three numbers, a,b and c. coefficients of the quadratic. Try to use a loop and try...catch to validate the input.
Handle the possible different cases:
1. Two distinct real roots. (discriminant >0)
2. One doubled real root (discriminant = 0)
3. Two complex conjugate roots. It is ok to just print out "No Real Roots" here, but it would be worth 10 points of extra credit if you could print out stuff like: (0.882+0.5i) and (0.882-0.5i)
4. Just one real root because it wasn't really a quadratic after all, it was a linear equation like 0x^2 + 3x + 4 = 0, which would have the root -4/3
5. All real numbers work: 0x^2 + 0x + 0=0, and number makes this true
6. No real numbers work: 0x^2 + 0x + 6 = 0 ain't gonna be true for any x
Finally, your whole code should be in a loop, so after calculating results, you should ask the user something like "More? (y/n)", and start over if the user says "y"..
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
