Question: c. Develop class Polynomial as follows: i. It has one field representing the coefficients of the polynomial using an array of double. A polynomial

c. Develop class Polynomial as follows: i. It has one field representing 


c. Develop class Polynomial as follows: i. It has one field representing the coefficients of the polynomial using an array of double. A polynomial is assumed to have the form ao + ax +...+ an-1xn-1. For example, the polynomial 6 - 2x + 5x would be represented using the array [6, -2, 0, 5] ii. It has a no-argument constructor that sets the polynomial to zero (i.e. it makes it a zero polynomial) iii. It has a constructor that takes an array of double as an argument and sets the coefficients accordingly iv. It has a method named add that takes one argument of type Polynomial and returns the polynomial resulting from adding the calling object and the argument v. It has a method named evaluate that takes one argument of type double representing a value of x and evaluates the polynomial accordingly. For example, if the polynomial is 6 - 2x + 5x and evaluate(-1) is invoked, the result should be 3. vi. It has a method named hasRoot that takes one argument of type double and determines whether this value is a root of the polynomial or not. Note that a root is a value of x for which the polynomial evaluates to zero.

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 Programming Questions!