Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! Super rusty with programming :( A single variable polynomial is represented as an arithmetic expression shown below: A_0 + A_1 middot x +

image text in transcribedPlease help! Super rusty with programming :(
A single variable polynomial is represented as an arithmetic expression shown below: A_0 + A_1 middot x + A_2 middot x^2 + ... + A_k middot x^k The highest exponent, k, is called the degree of the polynomial, and the constants A_0, A_1, ..., A_k are the coefficients. For example, here are two polynomials with degree 3: 2.1 + 4.8x + 0. 1x^2+ (-7.1)x^3 2.9 + 0.8x + + 1.7x^3 Design, and implement a class for polynomials. The class may contain a static member constant, MAX, which indicates the maximum degree of any polynomial (this allows you to store the coefficients in an array with a fixed size). The default constructor will be one which will initialize the polynomial with all coefficients set to zero. In addition, you must have another constructor that takes two parameters: degree, and coefficient_array which are used to initialize the polynomial appropriately. In addition you should have a member function that gets and sets the value of an appropriate coefficient. For example, get(k) returns the coefficient of x^k and set(k, 24.5) sets the coefficient of x^k to 24.5. You should provide a member function for evaluating a polynomial value for specific value of x, say x = 5.7. Please implement poly.cpp given the following poly.h header file: #ifndef POLY_H #define POLY_H class poly {public: static const int MAX = 10;//maximum degree is 9, maximum length of array is 10//CONSTRUCTORS poly();//a polynomial with degree 0 poly(const int k);//a polynomial with degree k poly(const int k, const double initial_coeff[]);//MEMBER FUNCTIONS void set(const int k, const double coeff);//sets the kth coefficient//CONSTANT MEMBER FUNCTIONS double get(const int k) const;//gets the kth coefficient int getdegree() const; double evaluate (const double xval) const;//evaluates the polynomial private: double data [MAX]; int degree;};} #endif

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How would we like to see ourselves?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago