subject

Requirements: The goal of assignment 3 is to reinforce the dynamic classes in C++. Specifically, the assignment is to implement the polynomial class from chapter 4.6 on page 212. But the additional requirement is to implement the class using a dynamic array to store the coefficients. The class needs to have a destructor, copy constructor, and an overloaded assignment operator. The following files are provided for your reference. You should start by modifying the header file first.
// FILE: poly0.h
// CLASS PROVIDED:
// class polynomial (in the namespace main_savitch_3)
// A polynomial has one variable x, real number coefficients, and
// non-negative integer exponents. Such a polynomial can be viewed
// as having the form:
// A[n]*x^n + A[n-1]*x^(n-1) + ... A[2]*x^2 + A[1]*x + A[0]
// where the A[n] are the real number coefficients and x^i represents
// the variable x raised to the i power. The coefficient A[0] is
// called the "constant" or "zeroth" term of the polynomial.
// // NOTES TO STUDENT:
// 1. This version works by storing the coefficients in
// a fixed array. The coefficient for the x^k term is stored
// in location [k] of the fixed-size array. Later we will modify
// the implementation to use a dynamic array.
// 2. Note that two functions have been implemented as inline functions
// in this file (the degree and operator() functions).
// 3. An implementation of the make_gif function is available for
// students to use at www. cs. colorado. edu/~main/projects/polygif. cxx.//
// MEMBER CONSTANTS
// const static size_t CAPACITY
// The size of the fixed array to store the coefficients.
// const static size_t MAX_EX = CAPACITY - 1;
// The maximum exponent permitted.
CONSTRUCTOR for the polynomial class
// polynomial(double c = 0.0, unsigned int exponent = 0)
// PRECONDITION: exponent <= MAX_EX.
// POSTCONDITION: This polynomial has been create with all zero
// coefficients, except for coefficient c for the specified exponent.
// When used as a default constructor (using default values for
// both arguments), the result is a polynomial with all zero
// coefficients.//
// MODIFICATION MEMBER FUNCTIONS for the polynomial class
// void add_to_coef(double amount, unsigned int exponent)
// PRECONDITION: exponent <= MAX_EX.
// POSTCONDITION: Adds the given amount to the coefficient of the
// specified exponent.
void assign_coef(double coefficient, unsigned int exponent)
// PRECONDITION: exponent <= MAX_EX.
// POSTCONDITION: Sets the coefficient for the specified exponent.//
// void clear( )
// POSTCONDITION: All coefficients of this polynomial are set to zero.
CONSTANT MEMBER FUNCTIONS for the polynomial class
// double coefficient(unsigned int exponent) const
// POSTCONDITION: Returns coefficient at specified exponent of this
// polynomial.
// NOTE: for exponents > MAX_EX, the return value is always zero.
unsigned int degree( ) const
// POSTCONDITION: The function returns the value of the largest exponent
// with a non-zero coefficient.
// If all coefficients are zero, then the function returns zero.//
// polynomial derivative( ) const
// POSTCONDITION: The return value is the first derivative of this
// polynomial.//
// double eval(double x) const
// POSTCONDITION: The return value is the value of this polynomial with the
// given value for the variable x.
unsigned int next_term(unsigned int e) const
// POSTCONDITION: The return value is the next exponent n which is LARGER
// than e such that coefficient(n) != 0.
// If there is no such term, then the return value is zero.//
// unsigned int previous_term(unsigned int e) const
// POSTCONDITION: The return value is the next exponent n which is SMALLER
// than e such that coefficient(n) != 0.
// If there is no such term, then the return value is UINT_MAX
// from .
CONSTANT OPERATORS for the polynomial class
// double operator( ) (double x) const
// Same as the eval member function.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Which action is good business etiquette? a. switching your cell phone off before you enter a meeting b. keeping your cell phone on low volume before you enter a meeting c. setting a pleasant ring tone on your cell phone before you enter a meeting d. setting a standard ringtone on your cell phone before you enter a meeting
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
These factors limit the ability to attach files to e-mail messages. location of sender recipient's ability to open file size of file type of operating system used
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Font size, font style, and are all aspects of character formatting.
Answers: 2
question
Computers and Technology, 24.06.2019 17:30
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 2
You know the right answer?
Requirements: The goal of assignment 3 is to reinforce the dynamic classes in C++. Specifically, th...
Questions
question
Health, 23.09.2019 22:40
question
Advanced Placement (AP), 23.09.2019 22:40
Questions on the website: 13722367