Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Do the following. Note: The print only has to show the coefficients of the polynomial after the operations. Write a program using classes

Using C++ Do the following.

image text in transcribed

Note: The print only has to show the coefficients of the polynomial after the operations.

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 defau 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 polyno 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 e main program will be in a different file name Recall that a polynomial of degree 3 has form: POx) ax3 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 Test your program with the following sets of values P1: 2, 3, 5, 8 P1: -2, -7, 7, -2 P2 -3, 6, -6, -7 Add P2 -1, -1, -6, -2 (Subtract) P1: s, o, o, -5 P1: 0, 8, 0, -4 P2 1, 1, 4, o (subtract) P2 0, -1, 3, 3 (Add)

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What are standard supply risks? How might they be mitigated?

Answered: 1 week ago