Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions