Question: This need to be done in java using linked list public class Polynomial { // this is a nested static class, it defines a type

This need to be done in java using linked list  public class Polynomial { // this is a nested static class, it defines a type // all the instance varaibles can be access directly inside Polynomial class even though they have // private modifier private static class TermNode{ private double coefficient; private int exponent; private TermNode next; public TermNode(int exp, double coeff, TermNode nextTerm ) { coefficient= coeff; exponent = exp; next = nextTerm; } } // instance variables of Polynomial // first is the term of the Polynomial with the highest degree private TermNode first; /**Postcondition: Creates a polynomial which is 0. * **/ public Polynomial() { first = new TermNode(0,0, null); } /**Postcondition: Creates a polynomial which has a single term a0*x^0 * @param a0 The value to be set as the coefficient of the constant (x^0) term. * **/ public Polynomial(double a0) { first = new TermNode(0,a0,null); } /**Postcondition: Creates a copy of Polynomial p * @param p the Polynomial which is to be copied. * **/ public Polynomial(Polynomial p) { } /**Postcondition: Adds the given amount to the coefficient of the specified exponent. * @param amount The amount to be added to the coefficient. * @param exponent The degree of the term whose coefficient is to be modified. * (1) Note that the exponent can be arbitrary * (2) If you want, you can assume the amount is not 0, however, it is possible that * after you add the amount, the coefficient becomes 0, in which case, you should delete the TermNode * **/ public void add_to_coef(double amount, int exponent) { } /**Postcondition: Sets the coefficient of a specified term to a specified value. * @param coefficient The new value of the coefficient. * @param exponent The degree of the term whose coefficient is to be modified. * (1) Note that the exponent can be arbitrary * (2) The coefficient may be 0 * **/ public void assign_coef(double coefficient, int exponent) { } /** Postcondition: Returns coefficient at specified exponent of this polynomial. * @param exponent The exponent of the term whose coefficient is sought. * @return The coefficient of the term. * @throws Exception if the degree of the activating polynomial is less than that of the requested term. * **/ public double coefficient(int exponent) { } /** @return The value of this Polynomial with the given value for the variable x. * @param x The value at which the Polynomial is to be evaluated. * using Horner's method to evaluation * see the link here * https://en.wikipedia.org/wiki/Horner%27s_method * ***/ public double eval(double x) { TermNode t = first; double sum = t.coefficient; int curExponent = t.exponent; while(t.next!=null) { } return sum; } /**@return True if p and this polynomial is same * @param p The polynomial to be tested for equality. * */ public boolean equals (Object obj) { if(obj instanceof Polynomial) { } return false; } /**@return Returns a string representing the polynomial expression with coefficients displayed to the tenths place, * omitting any coefficients that are zero. * If all coefficients are 0, then the zero function is reported. * **/ public String toString() { } /**@return Returns a Polynomial that is the sum of p and this Polynomial. * @param p The Polynomial to be added to the activating Polynomial. * **/ public Polynomial add(Polynomial p) { } /**Postcondition: Returns a new polynomial obtained by multiplying this term and p. For example, if this polynomial is 2x^2 + 3x + 4 and p is 5x^2 - 1x + 7, then at the end of this function, it will return the polynomial 10x^4 + 13x^3 + 31x^2 + 17x + 28. @param p The polynomial to be multiplied. @return The product of the activating Polynomial and p. **/ public Polynomial multiply(Polynomial p) { } } 

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!