Question: Write a program in Java to implement Horners algorithm. In other words, your program should evaluate the polynomial p(x) = anxn + an-1xn-1 + +

Write a program in Java to implement Horners algorithm. In other words, your program should evaluate the polynomial p(x) = anxn + an-1xn-1 + + a1x + a0 at a given point x.

Your program should prompt the user to enter the coefficients of the polynomial from the lowest degree to the highest degree and the number x. For example, to evaluate p(x) = 2x4 x3 + 3x2 + x 5 at x = 3, the user would input: -5 1 3 -1 2 and 3. Your program should display the coefficients of the polynomial and output the value of the polynomial at x. For example, p(3) = 160.

Sample output: Enter the degree of polynomial:6

Enter the value at which the polynomial is to be evaluted:3

Enter the coefficients of the polynomial starting with lowest degree: 5 2 0 -3 0 0 2

The coefficients of the polynomial are: 2 0 0 -3 0 2 5. The value of the polynomial at x=3 is 1388

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!