Write a java program that solves a quadratic equation for all cases. Set up the
ID: 642959 • Letter: W
Question
Write a java program that solves a quadratic equation for all cases.
Set up the following classes: Complex: which encapsulates a complex number, Complex Pair: which encapsulates a pair of complex numbers,Quadratic: which encapsulates a quadratic equation,Solve Equation: which contains the main method.
Along with the usual constructors, accessors and mutators, you will need to code the additional methods.
In Complex class: a method that determines whether a complex object is real
In the Complex pair class: a method that determines whether both complex numbers are identical
In the Quadratic class: a method to solve the quadratic equation and return a ComplexPair object.
Additionally, you need to include code in the main method that solve several examples of quadratic equations input from the keyboard.
Your output should make comments as to what type of roots we get ( double root, distinct real roots, distinct complex root).
You should check that your code works in all four basic cases:
? The quadratic equation is actually a linear equation
? Both roots are complex
? There is a double real root
? There are 2 distinct real roots.
I am new at Java programming, please help me!!!!!! thank you
Explanation / Answer
> So filter your input: you'll be accepting a, b, and c as inputs; these are the canonical
> variables. If a is zero, the equation is linear if c is nonzero. if the determinant is zero, there
> is only one real root. If c is zero, 0 is one of the roots. If the determinant is negative there are
> two complex roots, otherwise there are two real roots. It won't be hard.
>
> John (gnujohn)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.