Question: In the Testequationsstart. java file ( which you will save as Testequations. java ) , you are given an abstract class for equations in one
In the Testequationsstart. java file which you will save as Testequations. java you are given an
abstract class for equations in one variable: Equation. It represents an equation by the coefficients of a variable
and its powers, and has an abstract findsolution method that returns an array of double giving the roots of
the equation. You will write two concrete classes that extend this abstract class, as shown in the following UML
diagram:
The first class, LinearEquation, represents a linear equation of the form Thus the coefficients array
will have two entries. It has two constructors:
public LincarEquationdouble coefficients
public LinearEquationdouble a double b used to populate the cocficients property
Implement the
method, which will return an array of one double with the solution. Also,
implement a tastring method that returns a string in the form where both the numbers are
displayed with two digits to the right of the decimal point.
The second class, puadraticfquation, represents a quadratic equation of the form Thus the
array will have three entries. It has two constructors:
public Quadratickquationdouble cocfficients
public quadraticequationdouble a double b double c used to populate the coefficients property
Implement the findsolution method, which will return:
if there are no solutions to the equation.
an array of length one giving the root of the equation if there is only one root
an array of length two giving the roots of the equation if there are two roots
Hint: Put the coefficients for the quadratic equation into variables named and to make the code easier to
read.
Also, implement a method that returns a string in the form where all the numbers
are displayed with two digits to the right of the decimal point. Use uatebz to produce a superscript in the
output.
Use the Testequationsstart. java darr file as your starting point, and save it as Testequations java
Here is what the output of your finished program should look like:
When You Finish
Upload the TestEquation. java file. Remember to put comments at the start of the file that give your name, the
date you wrote the code, and a description of the program. The description must be sufficient for someone who
has not read the assignment to understand what kind of input is expected, what processing occurs, and what the
output is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
