Create a class Polynomial that is used to evaluate a polynomial function of x: 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 zero. 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(max)—a constructor that creates a polynomial of degree max
whose coefficients are all zero
• setConstant(i, value)—sets the coefficient ai to value
• evaluate(x)—returns the value of the polynomial for the given value x
For example, the polynomial
P(x) = 3 + 5 x + 2 x3 is of degree 3 and has coefficients a0 = 3, a1 = 5, a2 = 0, and a3 = 2. The invocation
evaluate(7) computes and
returns the result 724.
See the code in Polynomial.java.
You might also like to view...
To print a range of cells in the active worksheet, click ____ in the Print What area in the Print dialog.
A. Print Active Sheets B. Selection C. Print Entire Workbook D. none of the above
____________________ software is an application that helps you organize your calendar, keep track of contacts, and share this information with other devices or users.
Fill in the blank(s) with the appropriate word(s).
Most documents created using the WordPad program are saved with the ____ extension.?
A. ?.rtf B. ?.wpd C. ?.doc D. ?.docx
?If the file is not in the ____________________ for the website, Dreamweaver will prompt you to indicate whether or not you would like to copy it there.
Fill in the blank(s) with the appropriate word(s).