In this program class name “Polynomial” which contains an array of size (n) not dynamic allocation, Degree of polynomial may be in a global variable, to store the coefficients of the polynomial into the indices corresponding to their powers. For example if we want to make a polynomial 2x4 + 3x3 – 12x2 + x – 19 (degree-4) then the polynomial class will have an array of the following form.
0 1 2 3 4
-19
1
-12
3
2
Main constructor which initizlie array to zero, member function mulftiply that take an integer, Add function that return Polynomial after adding, subtract. To test the polynomial in Main program.
I have written the following code. Please help me to complete this program.
#include <iostream.h>
#include <stdlib.h>
class Polynomial
{
protected:
int size[n];
public:
Polynomial(){}
//Constructor, which initializes the array to zero
Polynomial (int degree);
//Prints the polynomial in the following format, 2x^4+3x^3-12x^2+x-19
void outputPolynomial();
//Multiply a polynomial with the input scalar value.
//Returns a new Polynomial object, which is the resultant polynomial
//after the multiplication operation b=a.MulPolyWITHScalar(Value)means b=a*value
Polynomial MulPolyWithScalar(int value);
//Adds two polynomials of the same degree.
//Returns a new Polynomial object, which is the sum of polynomial of
//calling object and the "poly".
Polynomial AddPolynomials (Polynomial poly);
//Subtracts a polynomial from another of the same degree
//Example: b = a.SubtractPolynomials(poly) means b = a - poly
Polynomial SubtractPolynomials (Polynomial poly);