The polynomial class should consist of a linked list of nodes accessed through head. You will need to create a class of terms (Objects representing the individual terms of the polynomial) The polynomial class will consist of linked nodes: class polynomial{ private node head; private int degree; The node (a node class in the same folder/package): protected terms term; protected node next; The terms (in the same folder/package) will consist of: protected double coeff; protected int power; And member methods: constructor(s) evaluate(x) add- which will add a polynomial q to the given polynomial p = p+q subtract – which will subtract a polynomial q from the given polynomial p = p-q scale = which will multiply the given polynomial by a constant a p =ap multiply – which will multiply the given polynomial by a polynomial q p = p*q and polynomial methods: sum – which adds 2 polynomials and creates a new polynomial without destroying the original r = p+q diff - which subtracts 2 polynomials and creates a new polynomial without destroying the originals r = p-q product - which multiplies 2 polynomials and creates a new polynomial without destroying the original r = p*q The polynomial should maintain the terms in order, sorted by the power. (hint: use the insertSorted method we designed in lecture, with the “order” using term.power.) You do not need to use the LinkedList class to do this project! You are just using the linked-structure style to manage the polynomials.
The polynomial class should consist of a linked list of nodes accessed through head.
You will need to create a class of terms (Objects representing the individual terms of the polynomial)
The polynomial class will consist of linked nodes:
class polynomial{
private node head;
private int degree;
The node (a node class in the same folder/package):
protected terms term;
protected node next;
The terms (in the same folder/package) will consist of:
protected double coeff;
protected int power;
And member methods:
constructor(s)
evaluate(x)
add- which will add a polynomial q to the given polynomial p = p+q
subtract – which will subtract a polynomial q from the given polynomial p = p-q
scale = which will multiply the given polynomial by a constant a p =ap
multiply – which will multiply the given polynomial by a polynomial q p = p*q
and polynomial methods:
sum – which adds 2 polynomials and creates a new polynomial
without destroying the original r = p+q
diff - which subtracts 2 polynomials and creates a new polynomial
without destroying the originals r = p-q
product - which multiplies 2 polynomials and creates a new polynomial
without destroying the original r = p*q
The polynomial should maintain the terms in order, sorted by the power. (hint: use the insertSorted method we designed in lecture, with the “order” using term.power.)
You do not need to use the LinkedList class to do this project! You are just using the linked-structure style to manage the polynomials.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 5 images