Question
In java, implement this interface in a class PolynomialImpl and using Array function. This implementation should have the following features/obey these constraints: This class should
In java, implement this interface in a class PolynomialImpl and using Array function. This implementation should have the following features/obey these constraints:
This class should store the polynomial using the a linked list with nodes. This representation must be implemented by you (i.e. you are not allowed to use existing list classes in Java).
This class should store only terms with non-zero coefficients.
This class should store the polynomial terms in decreasing order of their powers.
This class should have a constructor with no parameters that creates a polynomial with no terms, i.e. the polynomial 0 (how to represent this?).
This class should have another constructor that takes a polynomial as a string, parses it and creates the polynomial accordingly. The string contains the polynomial, with each term separated by a space. The following examples should work with your constructor: "4x^3 +3x^1 -5" "-3x^4 -2x^5 -5 +11x^1"
Hint: Break the string into substrings and process. You may find the Scanner and String classes helpful to do this.
Furthermore one can convert "23" into the integer 23 by using Integer.parseInt("23"). While you are free to write helper methods, you are not allowed to write any other public methods other than those in the interface and the above two constructors.
This class should include a toString method that returns a string that contains the polynomial.
The following examples should help you infer the required format: 52+42 5 x 2 + 4 x 2 creates the string 5x^2 +4x^1 -2 503+2+3 50 x 3 + x 2 + 3 creates the string -50x^3 +1x^2 +3 4+253210 4 x + 2 x 5 3 x 2 10 creates the string 2x^5 -3x^2 +4x^1 -10
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