Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A one-variable polynomial is an arithmetic expression of the form a0 + a1x + a2x 2 + ...+ akx k The highest exponent, , is

A one-variable polynomial is an arithmetic expression of the form a0 + a1x + a2x 2 + ...+ akx k The highest exponent, , is called the degree of the polynomial, and the constants a0, a1, ...ak, are the coefficients. For example, here are two polynomials of degree 3: 2.1 + 4.8 x + 0.1 x2 + (-7.1) x3 2.9 + 0.8 x + 10.1 x2 + 1.7 x3 Design a C++ class for polynomials. Your class should implement a constructor that accepts a vector of numbers and initializes the polynomial using it. The array contains the constants a0, a1, ...ak, in that specific order. In addition, your class should implement the following methods: add(p) which adds another polynomial p and returns the resultant polynomial subtract(p) which subtracts another polynomial p and returns the resultant polynomial multiply(p) which multiplies the polynomial by another polynomial p, and returns the resultant polynomial display() which displays the polynomial evaluate(double x) which evaluates the polynomial given a value for x, and returns the result findRoots() which, if the polynomial is of degree 2 or less, finds and prints the roots. Your main () should be a test for your polynomial. I will test your program using my own main, which might look like: int main (){ vector array1 {5, 0, 3.5, 16, -2}; vector array2 {1, -2, 0.5}; polynomial P1 (array1); polynomial P2 (array2); polynomial newP = P1.add (P2); newP.display(); P2.findRoots(); cout << the value of the polynomial is" << newP.evaluate(5) << endl;

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

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

ISBN: 978-0764535376

More Books

Students also viewed these Databases questions

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago