Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class named QuadraticEquation for a quadratic equation ax^2+bx+x=0. The

ID: 3633512 • Letter: D

Question

Design a class named QuadraticEquation for a quadratic equation ax^2+bx+x=0. The class contains:
.private data fields a, b, and c that represents three coefficients.
. a constructor for the arguments for a, b, and c.
.three get methods for a, b, and c.
.a method named getDiscriminant() that returns the discriminant, which is b^2-4ac
.the methods named getRoot1() and getRoot2() for returning two roots of the equation, or returning 0 if the discriminant is negative.

Write a test program that prompts the user to enter values for a, b, and c and displays the roots. If no roots for the equation, display "The equation has no roots."

Explanation / Answer

public class QuadraticEquation { private int a,b,c; public QuadraticEquation(int x,int y,int z) { a=x; b=y; c=z; } public int getA() { return a; } public int getB() { return b; } public int getC() { return c; } public int getDiscriminant() { return b*b-4*a*c; } public double getRoot1() { if(getDiscriminant()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote