Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need a help to complete this following code in Java. import java.util.LinkedList; import java.util.ListIterator; public class Polynomial { // this is a nested static class,
need a help to complete this following code in Java. import java.util.LinkedList; import java.util.ListIterator; 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 Term{ private double coefficient; private int exponent; public Term(int exp, double coeff ) { coefficient= coeff; exponent = exp; } } // instance variables of Polynomial // first is the term of the Polynomial with the highest degree private LinkedList termList; 1. public Polynomial() { termList = new LinkedList(); termList.add(new Term(0,0)); } 2. public Polynomial(double a0) { termList = new LinkedList(); termList.add(new Term(0,a0)); } 3. public Polynomial(Polynomial p) { } 4. public void add_to_coef(double amount, int exponent) { } 5. public void assign_coef(double coefficient, int exponent) { } 6. public double coefficient(int exponent) { } 7. public double eval(double x) { } The return value is the value of this polynomial with the given value for the variable x.
Do not use power method from Math, which is very low efficient
8. public boolean equals (Object obj) { if(obj instanceof Polynomial) { } return false; } 9. public String toString() { } 10. public Polynomial add(Polynomial p) { } 11. public Polynomial multiply(Polynomial p) { } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started