Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program. Separate as polymain.cpp, Polynomial.h, and Polynomial.cpp. Create a class called Polynomial for performing arithmetic with polynomials. In mathematics, a polynomial is an expression

C++ program. Separate as polymain.cpp, Polynomial.h, and Polynomial.cpp.

Create a class called Polynomial for performing arithmetic with polynomials. In mathematics, a polynomial is an expression consisting of variables and coefficients, that involves only the operations of addition, subtraction, multiplication, and non-negative integer exponents. A polynomial in a single variable x can always be written in the form: where are constants and x is the variable. 1. Class Polynomial must provide the followings: Constructors: Polynomial(double[] c, int degree); double c[] = {4, -5, 3.1 }; Polynomial poly(c); Polynomial(poly); Degree must be >= 0, else it is an error. Mutator/accessor: set(double[] a, int degree) new coefficients getCoefficients() return a copy of the coefficients getDegree() return the degree (inline) Functions: == : compare polynomials bool same = p1 == p2; cin >> poly degree coefficients cout << poly outputs "3.1x^2 5x + 4" f(double x) evaluate and return the value of the polynomial + : Polynomial p3 = p1 + p2; polynomial addition, where p1 and p2 are Polynomials, returns a polynomial. 2. Provide a main function to show the use of the class (polymain.cpp). 3. Provide the definition and implementation files (Polynomial.h and .cpp). Do not use any inline implementations except getDegree. Memory must be allocated and deallocated properly.

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_2

Step: 3

blur-text-image_3

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 Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago