Question: JAVA 2 Quadratic Functions In this part you will create a Quadratic class for dealing with quadratic functions. A quadratic function is a function of

JAVA

2 Quadratic Functions In this part you will create a Quadratic class for dealing with quadratic functions. A quadratic function is a function of the form ax2+bx+c. Create a Quadratic class with the following methods: public Quadratic(float a, float b, float c) Set up a quadratic function with the given coecients. public Quadratic add(Quadratic other): This method should add other to the current quadratic function and return the result as a new Quadratic.

public Quadratic subtract(Quadratic other): This method should subtract other from the current quadratic function and return the result as a new Quadratic.

public Roots findRoots(): This method should use the quadratic formula to nd the roots of the current quadratic function, returning an instance of the Roots class containing those roots. You must write the Roots class on your own - more details are given below. public String toString(): This method should return a String representation of the current quadratic function, e.g. 9x2 4x + 1

public boolean equals(Object other): This method should return true if the current quadratic function is equal to other and false otherwise. Note: Since the coecients are oats, comparing them directly probably wont work due to oating point imprecision. Instead of directly testing if two numbers are equal, check if their dierence is within some tolerance, e.g. 0.0001.

A main method: Like the previous class, demonstrate that all the methods work via welldocumented, well-formatted tests. You may want to include getters and setters for the coefcients in your implementation of Quadratic. Roots: An additional class for you to write to contain the roots of a quadratic formula

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!