Question: Write a test program (TestQuadraticEquation)that requests the user to enter three integer coefficients (a,b,and c). Use the data type int for these local variables and
Lab09 Quadratic Equation Class: Design a class named QuadraticEquation for a quadratic equation ax2+bx+c 0. The class contains: Private data fields a, b, and a that represent the coefficients. A constructor with arguments (eg newA, newB, and neuC) for a, b, and a. Three get methods (e.g. geta, get, getc) fora, b, adol A method named getDiscriminant that returns the discriminant, which is b-4ac. The methods named getRoot1) and getRoot2() for returning two roots of the equation: -b+b2-4ac 2a -b-vb2-4ac r1 and r2 = 2a These methods are useful only if the discriminant is non-negative. Let these methods return 0 if the discriminant is negative. Write a test program (TestQuadraticEquation) that requests the user to enter three integer coefficients (a, b, and c). Use data type int for these local variables and display the results 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". Use lu0OB2 to display the superscript 2. At the end of your program, use the Date class from the java util library that creates a Date object and displays the date and time using the tostring) method Example equations: Extract coefficients, then evaluate discriminant (b2- 4ac) to determine the number of roots -2x- -2-(4*1 1)20 (1 root) 0-(4 1-91-36 (2 roots) 2-(413)-8 (0 roots) Factoring: x +2x +3-0 (Negative discrininant) Factoring Factoring: x 3(x3) Factoring: Cannot Eactor Roots are -2.-3 Root 1 Sample runs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
