Answer to Question #198305 in C++ for Mohid but

Question #198305

(Polynomial Class) Develop class Polynomial. The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent, the term 2x4 has the coefficient 2 and the exponent 4. Develop a complete class containing constructor and destructor functions as well as set and get functions. Assume that the polynomial is in one variable and maximum possible degree is 5. The class also provide the following overloaded operator

 

a)      Overload the addition operator (+) add two Polynomials.

b)      Overload the subtraction operator (-) subtract two Polynomials.

c)      Overload the assignment operator assign one Polynomial to another.

d)      Overload the multiplication operator (*) multiply two Polynomials.

e)      Overload the addition assignment operator (+=), (-=), and multiplication assignment operator (*=).

 

 

1
Expert's answer
2021-05-25T17:40:19-0400
#include <iostream>
#include "Polynomial.h"
using namespace std;
int main()
{
Polynomial a, b, c, t;
a. enterTerms();
b. enterTerms();
t = a; 
cout << "\nFirst polynomial is:\n";
a. printPolynomial();
cout << "\nSecond polynomial is:\n";
b. printPolynomial();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c. printPolynomial();
cout << "\n+= the polynomials yields:\n";
a += b;
a. printPolynomial();
cout << "\nSubtracting the polynomials yields:\n";
a = t;
c = a - b;
c.printPolynomial();
cout << "\n-= the polynomials yields:\n";
a -= b;
a. printPolynomial();
cout << endl;
system("PAUSE"); 
return 0;
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog