Represent your polynomial as a recursive union.

Responsive Centered Red Button

Need Help with this Question or something similar to this? We got you! Just fill out the order form (follow the link below), and your paper will be assigned to an expert to help you ASAP.

To practice implementing a recursive union.
A polynomial is made of several terms, each term having a coefficient and a variable raised to a power. Polynomials are one-variable if all their terms contain only one variable. An example of such a polynomial is . This polynomial has four terms.
The degree of a polynomial is defined as the highest power of the variable in a term. In the above example, the degree of the polynomial is 4. The polynomials we deal with have only non-negative whole numbers as powers. The coefficients of our polynomials are integral numbers.
Two polynomials are the same if they contain the same terms.
Several algebraic operations are possible with polynomials. The simplest one is evaluating the polynomial for a specific value of the variable. For example, for a polynomial , its value at  is defined as  which is 40.0625.
Polynomials can be added together to create a new polynomial. The addition is performed by combining all the terms and adding the coefficients of the terms with the same power. For example  is  The degree of the sum is the maximum of the degrees of the two polynomials.
What to do
Assignment Directory: lab07-polynomials
Starter Files: Polynomial.java Download Polynomial.java
Package: polynomial
Start by the provided Polynomial interface and implement it in a class called PolynomialImpl. Beyond implementing the Polynomial interface, your implementation should have the following features/obey these constraints:
You are not allowed to use any of Java’s existing list implementations, interfaces, arrays, or otherwise any collection classes or maps to implement polynomials. You are required to represent your polynomial as a recursive union.
A polynomial should only store terms with non-zero coefficients.
This class should have a constructor with no parameters that create a polynomial with no terms, i.e., the polynomial 0.
This class should have another constructor that takes a polynomial as a string, parses it, and creates the polynomial accordingly. This string contains the polynomial, with each term separates by a space. The following examples should work with your constructor:
“4x^3 +3x^1 -5”
“-3x^4 -2x^5 -5 +11x^1”
“102”
“+3x^4 -2x^5 -5 -2x^4 +11x^1”
For this implementation, any term with a negative power is invalid.
This class must provide a way to determine if two polynomials are the same.
For the add method, if the current polynomial and the parameter are not implemented as the same concrete type, your solution should throw an IllegalArgumentException.
You are not allowed to implement the add method using a mix of string manipulation and the constructors below.
This class should include a toString method that returns a string representation of the polynomial. The following examples should help you infer the required format:
creates the string “5x^2 +4x^1 -2”
creates the string “-50x^3 +1x^2 +3”
creates the string “2x^5 -3x^2 +4x^1 -10”
The empty polynomial should create the string 0
Hint: You may find the Scanner class helpful to do this.
Testing
Whenever you write a class, you should also write tests for that class that proves not only that your code CAN work but that it WILL ALWAYS work. Additionally, your tests should be sufficient to convince someone else that your code works correctly.

How to create Testimonial Carousel using Bootstrap5

Clients' Reviews about Our Services