write it in java plz
Question 2. (Polynomial.java and PolynomialTester.java) Although it is quite advanced in many ways, the Equinox's main computer needs to be tested for some simple algebraic functionality ahead of the next research mission to planet Frobus 3. You have been tasked with writing a class called Polynomial that represents and evaluates polynomial expressions From your cadet training, you recall that a polynomial function of x takes the form: Px)= , + axtar +...+2, 2x*-+ax where coefficients a, are floating-point (decimal) numbers, the exponents of x are integers, and the largest exponent called the degree of the polynomialis greater than or equal to zero. It sounds complicated but it might not be as bad as you think. Your Java class is defined by two data fields, one that represents the degree of the polynomial (the value of largest exponent n) and the other is a 1D array of coefficients al. Thus if the value of n is 4 and the coefficients in the array are in order) 7.2.5.0.1 the corresponding polynomial is 7+2x+5x+x* Coefficients can be integers or doubles. Below is the UML diagram for this class SSSSSSSS T EXANS Polynomial -degree in SSS -coefficiente double Polynomial (deg Tin Polynomial Polynomial set coefficient index fint, Valse double get coefficient indexint) double -evaluate double double tostengt) String equalsiob boolean Here are some extra hints to help you along Polynomial (deg i nt) this is an argumented constructor that creates a new polynomial object with degree deg The coefficients will all be 0 after the object is created Polynomial (PPolynomial this is a copy constructor. It should take an existing polynomial object as an argument and should create a new one with the same degree and coefficients. set coefficient.getCoettcient should be straightforward (I think?!). Note: If the user enters invalid indices, do nothing (change no coefficient value, get no coefficient value) evaluate (x: double) this method renuns the computed value of the polynomial given the value of argument. If we use our previous example polynomial 742x45x+x the value of this polynomial for a value of x-3 would be: 7+2(3)+5(3) + (3)=139. You'll need a loop to access all of the coefficients. ELER Edit View Window Help MO cosc1046-a1-w20.pdf sc1046-a1-w20... * 1 @ 4 / 13 A my 81.1% equals (obj2): compares to Polynomials (or a polynomial and another object) for equality. Two polynomials are considered equal IFF they have the same degree and all the same coefficients (in the same order) toString(): displays a polynomial to the console (see sample output on next page). Use a loop to constructor your Write JavaDocs for the Polynomial class (not the tester). REMEMBER - your tester class will do the input and output work; it will make use of your object. There should be NO Scanners in the Polynomial class. Keep your methods generalized - data comes in through arguments and out through return statements. Q 13c 81.1% . Write an application class called PolynomialTester that accomplishes the following: Prompt the user to enter the degree of the desired polynomial. Call your constructor and create the basic polynomial. At least make sure that the degree is positive and greater than zero (i.e., input validation) Prompt the user to enter all the necessary coefficients. Use a loop and your setCoefficient () method to set the coefficients for your polynomial. Display the completed" polynomial Prompt the user to enter in a value for x (double or int are both fine). Evaluate the polynomial for that value of x and display the result. Use a sentinel loop to re-prompt the user to enter other values of x and to keep computing the evaluated polynomial until they enter the string quit Before quitting, create a copy of the polynomial using your copy constructor. Show that they are equal using your equals() method and by printing them both out to the screen. Then allow the user to change one coefficient of their choice and show that they are different (use equals() and display to the screen). This is not shown in the sample output below. Write proper Java docs for your Polynomial.java source file and write normal comments for your tester. Enter polynomial degree: Coeff fot degree 0: 7 Coeff for degree 1:2 Coeff for degree 2: 5 Coeff for degree 3: 0 Coeff for degree 4: 1 Polynomial: 7.0 + (2.0)x1 + (5.0) x^2 + (1.0) x^4 Enter a value of x for which to evaluate the polynomial: 3 For x = 3, polynomial = 139.0 Enter a value of x for which to evaluate the polynomial-3. For x = -3.1, polynomial = 141.2021 Enter a value of x for which to evaluate the polynomial: 9.26 For X = 9.26, polynomial = 7806.9089057599995 Enter a value of x for which to evaluate the polynomial! cruit