Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 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 \u00B2 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 toSpring() method. See pic. image text in transcribed
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

DESCRIBE six government-sponsored benefits.

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago