Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a class, Polynomial, to represent single-variable polynomials and write a test program. The functionality of the Polynomial class is as follows: - Provide at

Implement a class, Polynomial, to represent single-variable polynomials and write a test program. The functionality of the Polynomial class is as follows:

- Provide at least three constructors: a zero-parameter constructor that makes the polynomial zero, a constructor that makes a separate independent copy of an existing polynomial, and a constructor that creates a polynomial based on a String specification. The last constructor can throw an exception if the String specification is invalid, and you can make a design decision on what a valid specification is.

- negate returns the negative of this polynomial.

- add, subtract, and multiply return a new polynomial that is the sum, difference, or product, respectively, of this polynomial and another polynomial, rhs. None of these methods change either of the original polynomials.

- equals and toString follow the standard contract for these functions. For toString make the String representation look as nice as you can.

- The polynomial is represented by two fields. One, degree, represents the degree of the polynomial. Thus x2+2x +1 is degree 2, 3x + 5 is degree 1, and 4 is degree 0. Zero is automatically degree 0. The second field, coeff, represents the coefficients (coeff[i] represents the coefficient of xi ).

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

Database Systems For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions