Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago