Question: Using JAVA, implement DensePolynomial class. There can only be one instance variable in DensePolynomial, and it must be private and final and of type double[]

Using JAVA, implement DensePolynomial class. There can only be one instance variable in DensePolynomial, and it must be private and final and of type double[] .

Implement DensePolynomial addTerm(coefficient, degree) /** * Return a new Polynomial that includes the supplied coefficient and degree * term. If the supplied term is of the same degree as an already existing Term * in this Polynomial, then the coefficients of the supplied and existing terms * are summed in the returned new Polynomial. * * This Polynomial must not be disturbed by this method. Be sure to return a new * Polynomial that is like this one, but with the extra term included. * * @param coefficient * @param degree * @return new Polynomial as described above */ public Polynomial addTerm(double coefficient, int degree);

Implement DensePolynomial degree() /** * Return the degree of this Polynomial, computed as the highest degree Term of * this Polynomial over all Terms with non-zero coefficients. The degree of all * Polynomials is at least 0, because a Polynomial with no Terms is equivalent * to 0.0 x^0 * * @return the degree of this Polynomial */ public int degree();

Implement DensePolynomial getCoefficientAtDegree(degree)/**

 * Returns the coefficient of the term at the specified degree. If no such term * exists in the Polynomial, 0.0 should be returned. * * @param degree of interest * @return coefficient of the degree of interest */ public double getCoefficientAtDegree(int degree); 

Implement DensePolynomial evaluate(x)

/** * Evaluate this Polynomial at the specified value for x * * @param x value of the unknown * @return the sum of all terms evaluated at x */ public double evaluate(double x); 

To support the implementation of derivative() and sum(other) you may choose to build a second, private constructor here. What parameter it should take?

Implement DensePolynomial derivative()

/** * Returns a new Polynomial that is the derivative of this one. Be sure not to * modify this Polynomial. * * @return */ public Polynomial derivative(); 

Implement DensePolynomial sum(other)

/** * Return a new Polynomial that is the sum of this one and the other one. Be * sure not to disturb this Polynomial. * * @param other another Polynomial * @return the sum of this and the other Polynomial */ public Polynomial sum(Polynomial other); 

Implement a reasonable DensePolynomial toString()

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!