Question: JAVA Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x

JAVA

Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x = 0. The class defines the following variables and methods:

Private data field a, b, and c that represent three coefficients.

A constructor for the arguments for a, b, and c.

Three get methods for a, b, and c.

Method getDiscriminant()returns the discriminant value, which is disc = b2 4ac.

Method getRoot1() returns first root if the discriminant is not negative. First root is defined as

R1 = (-b + SquareRoot (disc) ) / 2a

Method getRoot2() returns second root if the discriminant is not negative. Second root is defined as

R2 = (-b - SquareRoot (disc) ) / 2a

Note that if the discriminant values is negative, the roots are Undefined.

Write a test program (name it testEquation) to create objects and test the class methods. Organized your output following these sample runs.

Sample run 1 for 3x2+ 8x + 4:

a = 3 b = 8

c = 4

Root 1 = -0.6666666666666666

Root 2 = -2.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!