Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java: Design an interface Polynomial that defines a recursive function. DO NOT USE ANY HASH FUNCTION. This is your polynomial abstract data type. Specifically

In Java:

Design an interface Polynomial that defines a recursive function. DO NOT USE ANY HASH FUNCTION. This is your polynomial abstract data type. Specifically this interface should have the following method signatures:

  • A method addTerm that takes a coefficient and a power (both integral numbers) and adds the resulting term to the polynomial. (This will enable you to build a polynomial term-by-term.) It should throw an IllegalArgumentException if a negative power is passed to it.

  • A method removeTerm that takes a power and removes any and all terms in the polynomial with that power.

  • A method getDegree that returns the degree of this polynomial.

  • A method getCoefficient that takes a power and returns the coefficient for the term with that power.

  • A method evaluate that takes a double-precision decimal number and returns a double-precision result.

  • A method add that takes another Polynomial object and returns the polynomial obtained by adding the two polynomials. Any implementation should ensure that this method does not mutate either polynomial. The implementation may assume that the given Polynomial is the of the same concrete class as this object; if it is a different class, the method may throw an IllegalArgumentException.

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago