Question: JAVA Please Help. I need help with evaluate() and Polynomial(int[] c) been trying to get solutions for days no luck. I posted a picture of

JAVA

Please Help. I need help with evaluate() and Polynomial(int[] c) been trying to get solutions for days no luck. I posted a picture of how the outcome should be. Thanks in advance.

JAVA Please Help. I need help with evaluate() and Polynomial(int[] c) been

trying to get solutions for days no luck. I posted a picture

of how the outcome should be. Thanks in advance. public class Polynomial

public class Polynomial private int coefficients; the constructor creates a Polynomial with the specified coefficients (passed as the parameter c) It should set the coefficients instance variable to be an array which is a copy of c At the end, the constructor calls the "simplify" method, which makes sure that the first coefficient(s) of the polymonial are non-zero. public Polynomial(int[ c) coefficients new int length] complete this make sure that the first coefficient of the polynomial is not e simplify(); simplify should (if necessary) create a new array to be stored in the coefficients instance variable In the new array, the first coefficient will be nonzero. For example, int coeffs fe, e, 2, 1, Polynomial p new Polynomial (coeffs) p represents the function f(n) en 4 en 3 2n 2 n. We would like to get ride of the highest order term (s) with coefficient of 0. In this example after calling p. simplify() p's coefficients should be 12, 1, 01, which represents f(n) 2n 2 n public void simplify() int i; for (i e; i coefficients length && coefficients[ i++) fill in the code for this method System.out.println(coefficients); int[ newCoeff new int[coefficients.length i]; for (int j j newcoeff.length; j++){

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!