Question: javadocs and comment needed please Not all object class represent tangible items. Write a class called Polynomial that represents and evaluates a polynomial expression. Recall
javadocs and comment needed please
Not all object class represent tangible items. Write a class called Polynomial that represents and evaluates a polynomial expression. Recall that a polynomial function of x takes the form: P(x) = a_1 + a_1x + a_2 x^2 + ... + a_a-1 x^-1 + a_n x^n where coefficients a are floating point numbers, the exponents of x are integers, and the largest exponent n-called the degree of the polynomial is greater than or equal to zero. It sounds complicated but it might not be as bad as you think. Your class is defined by two data fields, one that represents the degree of the polynomial (the value of largest exponent R) and another that is a 1D array of coefficient at. 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^3 + x^4. Coefficients can be integers or doubles. Below is the UML diagram for this class. Polynomial (digit) this is an garmented constructor that creates a new polynomial object as an argument and abound create a new one with the same degree and coefficients. Set Coefficient, get Coefficient should be straight forward. evaluate (x:double): this method returns the computed value of the polynomial given the value of argument x. If we use our previous example polynomial 7 + 2x + 5x^2 + x^4, the value of this polynomial for a value of x = 3 would be: 7 + 2(3) + 5(3)^2 + (3)^4 = 139. you'll need a loop to access all of the coefficients. equals 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)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
