Question: I need help with a JAVA program: Implement the following: Methods: An instance variable coeffs, which stores the polynomial coefficients in an array of double
I need help with a JAVA program:
Implement the following:

Methods:
An instance variable coeffs, which stores the polynomial coefficients in an array of double of size n + 1, where c0 is stored in position 0 and so successively. A MyPolynomial constructor (coeffs: double []) that receives a doubles array to initialize the coeffs array. A getDegree () method that returns the degree of the polynomial. A toString () method that returns "cnx ^ n + cn-1x ^ (n-1) + ... + c1x + c0" An evaluate (double x) method that evaluates the polynomial given an x (substituting x in the polynomial expression).
Add () and multiply () methods that add and multiply this polynomial with the other instance of MyPolynomial given, and they return this instance (which contains the Outcome). Test the implementation in a class called TestMyPolinomial, make sure that you try all the methods
MyPolynomial -coeffs: double[] +MyPolynomial(coeffs: double...) +getDegree():int +toString(): String ----- +evaluate(x: double): double +add(right:MyPolynomial) MyPolynomial +multiply(right: MyPolynomial) MyPolynomial - "CnX^n + Cn-1*^(n 1) + ... +Cjx + C
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
