Question: Java Please 5 Polynomials ( 30 points) Write a class Poly.java to represent polynomials (ie, functions of the form axn+bxn1++cx2+ dx+e). Implement the following methods:

Java Please
 Java Please 5 Polynomials ( 30 points) Write a class Poly.java

5 Polynomials ( 30 points) Write a class Poly.java to represent polynomials (ie, functions of the form axn+bxn1++cx2+ dx+e). Implement the following methods: - Poly(int]] coefficients): Constructor for an array of coefficients where c[n] is the coefficient of xn. In other words, the polynomial 2x5+3x48x2+4 would be represented by the array [4,0,8,0,3,2]. This way, if I want to know the coefficient of x2, I look at c[2], and get -8. This convenience is worth the confusion that arises because we usually write arrays leftto-right starting from the smallest index, whereas we usually write polynomials left-to-right starting from the largest coefficient. - int degree(): Return the power of the highest non-zero term - String toString(): Overriding the Object class's toString method, this should return a String representation of the polynomial using x as the variable, arranged in decreasing order of exponent and printing nothing for terms with a coefficient of zero. For example, the Poly represented by the array [4,0,8,0,3,2] should return the string: 2x5+3x48x2+4 - Poly add(Poly a): To add two polynomials, simply add together each scale degrce in turn. Thus, (2x5+3x48x2+4)+(x3+4x22x)=(2x5+3x4+x34x22x+4). Create a method that constructs and returns a new Poly object with a new coefficient array created by adding the coefficients of the current object and the Poly object a passed as an argument to the add() function. - double evaluate (double x ): Return the value of the function at the point x. In other words, if the Poly object represents 2x5+3x48x2+1 and cvaluate (2.0) is called, the method should calculate 2(2)5+3(2)48(2)2+1 and return 81 . Within the main() method of the Poly class, create a serics of tosts which exercise each of these methods and report their success or failure

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!