Question
(Algebra: quadratic equations) Design a class named QuadraticEquation for a quadratic equation . The class contains:
- Private data fields , and c that represent three coefficients.
- A constructor with the arguments for , and .
- Three getter methods for a, b, and c.
- A method named getDiscriminant () that returns the discriminant, which is .
- The methods named getRoot1 ( ) and getRoot2 () for returning two roots of the equation
These methods are useful only if the discriminant is nonnegative. Let these methods return 0 if the discriminant is negative.
Draw the UML diagram for the class then implement the class. Write a test program that prompts the user to enter values for , and and displays the result based on the discriminant. If the discriminant is positive, display the two roots. If the discriminant is 0 , display the one root. Otherwise, display "The equation has no roots." See Programming Exercise for sample runs.
Solution
VerifiedAnswered 1 year ago
Answered 1 year ago
Step 1
1 of 10To start, we're going to make a UML diagram of the class:
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Related questions
computer science