Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 4.1 For this problem you will be making your own package called mymath. This package will have two classes: Poly and PolyCalc. Both classes

image text in transcribed
Problem 4.1 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 + Bx-2 ... Ux3 + Wx2 + Yx + Z. It has one constructor that takes an array of double coefficients of size n (n > 0). L.e., you can assume that only non-empty arrays will be passed to the constructor. For example, to make the polynomial 4x2 + 3x - 2, it should be made this way now Poly(now doublo[14, 3, -21). The same polynomial could also be made this way now Poly(now doublo[]{0, 0, 0, 4, 3, -21). You are free to store these parameters however you choose. Poly has a method called evaluale (). 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 printPoly). This method should print the polynomial out in the form mentioned above: ax + box + cx + d. However, terms with O coefficients should be omitted. For example, the polynomial 5.5x - 3.1x + 3 should be printed as: "5.5**3 - 3.7x*7 + 3.0". If the Poly has all O 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 differentiale() 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 [0, 0, 0, 1, 0]. Also, you do not need to round coefficients.
image text in transcribed
-Problem 4.1- for this problem you will be making your own package called mymath. This package will have two claus Poly and Polycale feth cleos require complete dovador document comments Alus make sure you create the package and add both classes to it. Poly This class will model a polynomial of the form. Art. uwwer 2 It has one constructor that takes an array of double coefficients of size nu in > 0Le, you can assume that only non-empty arrays will be passed to the constructor For example to make the polynomial de? 3x-2, it should be made this way now Volytrow $03301154. 3.-21). The same polynomial could also be made this way plyter 00140. Po 00:-? You are free to store these parameters however you choose Poly has a method called valstu (). This method will return the double value of the polynomial evaluated for a given a you can tap intojwa lang bath for some handy maths operators Pay he pod caled peintboly. This method should print the polynomial out in the form mentioned abovewe bre? exod. However, terms with becaulicients should be omitted. For example, the polynomial 5.5 - 3.1x + 3 should be printed as 5.1 3.1 3.1 :If the Poly has all O coeficients, print an empty Sering You can define accessor methods for Poly and keep track of any other attributes you like Poly Cale 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 clans to make this possible, we simply need to define a member state . Polyak has a static method called Cert) This method should cakulate the coefficients for the derivative of the wpplied Poly object 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 Polycak has a static method caled at this method should calculate the coefficients for the integral of the supplied Poly object. It should then create a new Poly object from these coefficients and return it. Assume the integration constant is always the new coefficiente 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, 11, the new array should then be 10, 0, 01, . Also, you do not need to round coefficients - Problem 41- For this problem you will be making your own package called mymath. This package will have two classes: Poly and Polycale Both classes require complete Javadoc document comments. Also make sure you create the package and add both classes to it. Poly This elas will model a polynomial of the form Ave BU+Wx? + **+ Z. It has one constructor that takes an array of double coefficients of sizen in Olte, you can assume that only non-empty arrays will be passed to the constructor For example, to make the polynomial 4x2 + 3x - 2. It should be made this way new Poly the double th14, 3, -2). The same polynomial could also be made this way.com Polydou double (160, 0, 0, 4, 3, -21). 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 a rig Mitt for some handy matra operators Polyhos a method called print Poly This method thould print the polynomial out in the form mentioned above ar birad. However, terms with O coefficients should be omitted. For example, the polynomials. 3.1x 3 should be printed as -5.5x3 - 3.1x*1.3.0" If the Poly has all coefficients, print an empty String - You can define accessor methods for Poly and keep track of any other attributes you like Polycale This class will contain some calculus we can perform on a Poly object. You do not need to define a constructor. This class wil behave as a utility class in the sense that we do not need to create an instance of the class to access its members, jualang Math is another cample of this kind of class. To make this possibin, we simply need to define a member as state Polycalc has a static method caled 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 atray should ALWAYS be the same length as the original array. Abo, you do not need to round coefficients PolyCalc has a static method caled 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 cortant is always 0. The new coefficients artwy should ALWAYS be the same length 1 as the original array integrals go up an order). It does not matter if the original arrays (0, 0, 0, 1). the new array should then be (0, 0, 0.1, 0) Also, you do not need to round coefficients

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions