Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA CODE ONLY . I will upvote, thanks.. Response to comment left: No specific variables are required.. For this problem you will be making your
JAVA CODE ONLY. I will upvote, thanks..
Response to comment left: No specific variables are required..
For this problem you will be making your own package called mymath. This package will have two classes: Poly and PolyCalc. Both classes require complete Javadoc document comments. Also make sure you create the package and add both classes to it. Poly: This class will model a polynomial of the form: Axn-1 + Bxn-2 ... Ux3 + Wx? + Yx + Z. It has one constructor that takes an array of double coefficients of size n (n > 0). I.e., you can assume that only non-empty arrays will be passed to the constructor. For example, to make the polynomial 4x + 3x 2, it should be made this way new Poly(new double/K4, 3, -2}). The same polynomial could also be made this way new Poly(new double[K0, 0, 0, 4, 3, -2}). You are free to store these parameters however you choose. Poly has a method called evaluate(). This method will return the double value of the polynomial evaluated for a given x (you can tap into java.lang.Math * for some handy maths operators). Poly has a method called print Poly(). This method should print the polynomial out in the form mentioned above: ax3 + bx? + cx + d. However, terms with 0 coefficients should be omitted. For example, the polynomial 5.5x3 - 3.1x + 3 should be printed as: "5.5x^3 - 3.1x^1 + 3.0". If the Poly has all 0 coefficients, print an empty String. You can define accessor methods for Poly and keep track of any other attributes you like. PolyCalc: This class will contain some calculus we can perform on a Poly object. You do not need to define a constructor. This class will behave as a utility class in the sense that we do not need to create an instance of the class to access its members. java.lang.Math is another example of this kind of class. To make this possible, we simply need to define a member as static. PolyCalc has a static method called differentiate(). This method should calculate the coefficients for the derivative of the supplied Poly object. It should then create a new Poly object from those coefficients and return it. The "new coefficients" array should ALWAYS be the same length as the original array. Also, you do not need to round coefficients. PolyCalc has a static method called integrate(). This method should calculate the coefficients for the integral of the supplied Poly object. It should then create a new Poly object from those coefficients and return it. Assume the integration constant C is always 0. The "new coefficients" array should ALWAYS be the same length + 1 as the original array (integrals go up an order). It does not matter if the original array is [0, 0, 0, 1), the new array should then be [O, 0, 0, 1, 0]. Also, you do not need to round coefficientsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started