# Create a class Polynomial that is used to evaluate a polynomial

Create a class Polynomial that is used to evaluate a polynomial function of x:
P(x) = a0 + a1x + a2x2 + … + an-1xn-1 + anxn
The coefficients ai 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 0. The class has the attributes:
• Degree – the value of the largest exponent n
• Coefficients – an array of the coefficients ai
and the following methods:
• Polynomial(n) – a constructor that creates a polynomial of degree n whose coefficients are all 0.
• setCoefficient(i, value) – sets the coefficient ai to a value
• evaluate(x) – returns the value of the polynomial for the given value x
For example, the polynomial
P(x) = a0 + a1x + a2x2 + … + an-1xn-1 + anxn
is of degree 3 and has coefficients of a0 = 3, a1 = 5, a2 = 0, a3 = 2. The invocation evaluate(7) computes 3 + 5 x 7 + 0 x 7 + 2 x 73, which is 3 + 35 + 0 + 686, and returns the result 724.
To test your Polynomial class, create a driver class and paste the following code in the main method of your driver:
Polynomial p = new Polynomial(3);
p.setCoefficient(0, 3);
p.setCoefficient(1, 5);
p.setCoefficient(2, 0);
p.setCoefficient(3, 2);
System.out.println(p.evaluate(7));
Using the above code in your driver class should produce 724 as output. Your Polynomial class must work with the above code.
FIND ATTACHED FOR SOLUTION. SEE SCREENSHOT FOR SUCCESFUL PROGRAM OUTPUT =724