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 06:50
Match the personality traits with their description
Answers: 1
question
Computers and Technology, 22.06.2019 14:30
The “rule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
question
Computers and Technology, 22.06.2019 22:40
When you type the pwd command, you notice that your current location on the linux filesystem is the /usr/local directory. answer the following questions, assuming that your current directory is /usr/local for each question. a. which command could you use to change to the /usr directory using an absolute pathname? b. which command could you use to change to the /usr directory using a relative pathname? c. which command could you use to change to the /usr/local/share/info directory using an absolute pathname? d. which command could you use to change to the /usr/local/share/info directory using a relative pathname? e. which command could you use to change to the /etc directory using an absolute pathname? f. which command could you use to change to the /etc directory using a relative pathname?
Answers: 3
question
Computers and Technology, 23.06.2019 05:20
What did creator markus “notch" persson initially call his game
Answers: 1
You know the right answer?
Requirements: The goal of assignment 3 is to reinforce the dynamic classes in C++. Specifically, th...
Questions
question
Computers and Technology, 24.11.2020 23:10
question
Social Studies, 24.11.2020 23:10
question
Mathematics, 24.11.2020 23:10
Questions on the website: 13722361