Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ Do the following and follow the requirements. You are to have 3 files;

ID: 3802040 • Letter: U

Question

Using C++ Do the following and follow the requirements.

You are to have 3 files;

1) the class declaration in a single file

2) the main function which contains the input and menu function

3) the class definitions in another file.

The program should allow the user to enter the coefficients of two polynomials and then subtract or add them based on the users choice of to '+' or '--'

Write a program using classes that will add and subtract polynomials of degree up to 3 only. The program will have the following features: a. A class called Polynomial with 2 constructors (The default and another one) b. Two member functions: One to add and another to subtract the polynomials. c. One member function to print a polynomial d. There must be only four variables of type integer in this class. Note: 1. All the functions must be member functions, except the menu and input functions 2. The menu will allow the user to select either to add or to subtract two polynomials. 3. After the operation selection allow user to enter the coefficients of both polynomial 4. All the variables needed for the student class must be declared private 5. The print function should display the polynomial in standard form 6. The Polynomial Class declaration. will be in poly.h Use #ifndef, #define directives 7. The Polynomial Class definitions will be in poly.cpp 8. The main program will be in a different file name. Recall that a polynomial of degree 3 has form: POx) ax bx cx d Note: The functions add and subtract will receive either a reference to the other polynomial or a pointer to the class if you decide to allocate memory from the heap (Best). Since these values are private you will need to create a function to retrieve these values for them to be added or subtracted. Always if you use heap memory do not forget to free the memory at the end.

Explanation / Answer

class Polynomial { private: double *coefficients; //array to store the coefficients int degree; public: Polynomial(); //default constructor Polynomial(double[], int); //the constructor to initialize a polynomial //the operations for Polynomial class Polynomial operator+(Polynomial p) const; Polynomial operator-(Polynomial p) const; Polynomial operator*(Polynomial p) const; }; //default constructor Polynomial::Polynomial() { degree = 0; coefficients = new double[degree + 1]; coefficients[0] = 0; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote