### Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed ##### Bhupal ObraoiLaw
(5/5)

Hire Me ##### Edwin BenningLaw
(5/5)

Hire Me ##### Rooma KalranMarketing
(5/5)

Hire Me (5/5)

Hire Me

### The goal of this problem set is to extend the solution of tutorial 3. In particular, we wish to add methods to calculate a polynomial and to determine a polynomial’s derivative and it’s indefinite and definite integral

INSTRUCTIONS TO CANDIDATES

COS30008 Semester 1, 2020 Dr. Markus Lumpe 2 Problem Set 1: Solution Design in C++ The goal of this problem set is to extend the solution of tutorial 3. In particular, we wish to add methods to calculate a polynomial and to determine a polynomial’s derivative and it’s indefinite and definite integral. Start with the solution of tutorial 3 (see Canvas). Do not edit the provided files. Rather create a new .cpp unit, called PolynomialPS1.cpp, to implement the new methods. Please note that in C++ the implementation of a class does not need to occur in just one compilation unit (i.e., a .cpp file). As long as the compiler and the linker see all definitions, the build process should succeed, if the program does not contain any errors. Remember, a polynomial can be expressed concisely by using summation notation: That is, a polynomial can be written as the sum of a finite number of terms aix i . Each term consists of the product of a number ai, called the coefficient, and a variable x raised to integer powers – x i . The exponent i in x i is called the degree of the term aix i . The degree of a polynomial is the largest exponent of any one term with a non-zero coefficient. To calculate a polynomial, we need to provide a value for the variable x. Mathematically, we can write to denote the result of calculating a polynomial for a given value of x. Again, this allows for a straightforward mapping to a for-loop is C++. To compute the x i , we need to use the function pow, called raise-to-power, which is defined in cmath. For more details and example uses of pow, see http://www.cplusplus.com/reference/cmath/pow/. Please refer to PolynomialMath.pdf available on Canvas to review how one can compute the differential and integral of a polynomial. An understanding of the mathematical principles is essential for the successful completion of this assignment. Remember, polynomials appear frequently in computer science and software engineering. A notable example it polynomial time complexity of algorithms, that is, algorithms that are effectively computable. !n i=0 aixi f(x) = !n i=0 aixi COS30008 Semester 1, 2020 Dr. Markus Lumpe 3 The extended specification of class Polynomial is shown below. You only need to implement the last four methods. The other features (i.e., constructor and operators) are given as part of the solution for tutorial 3. In the .cpp file for the new methods you need to include cmath that contains the definition of pow – raise to power. #pragma once #include #define MAX_DEGREE 20+1+1 // max degree 0 to 20 plus 1 for integral class Polynomial { private: int fDegree; // the maximum degree of the polynomial double fCoeffs[MAX_DEGREE]; // the coefficients (0..10, 0..20, 0..21) public: // the default constructor (initializes all member variables) Polynomial(); // binary operator* to multiple to polynomials // arguments are read-only, signified by const // the operator* returns a fresh polynomial with degree i+j Polynomial operator*( const Polynomial& aRight ) const; // binary operator== to compare two polynomials // arguments are read-only, signified by const // the operator== returns true if this polynomial is // structurally equivalent to the aRHS polynomial bool operator==( const Polynomial& aRHS ) const; // input operator for polynomials friend std::istream& operator>>( std::istream& aIStream, Polynomial& aObject ); // output operator for polynomials friend std::ostream& operator<<( std::ostream& aOStream, const Polynomial& aObject ); // new methods in problem set 1 // call operator to calculate polynomial for a given x (i.e., aX) double operator()( double aX ) const; // compute differential // the differential is a fresh polynomial with degree fDegree-1 // the method does not change the current object Polynomial getDifferential() const; // compute indefinite integral // the indefinite integral is a fresh polynomial with degree fDegree+1 // the method does not change the current object Polynomial getIndefiniteIntegral() const; // calculate definite integral // the method does not change the current object // the method computes the indefinite integral and then calculates it // for xlow and xhigh and returns the difference double getDefiniteIntegral( double aXLow, double aXHigh ) const; }; COS30008 Semester 1, 2020 Dr. Markus Lumpe 4 Please note the changed value of MAX_DEGREE. Since we wish to build integrals, we need to reserve one more slot it the array for the coefficients of a polynomial. Our program supports polynomials up to the 10th degree. Multiplying them results in a polynomial up to the 20th degree, whose integral is up to the 21st degree. Hence, we need 22 entries in the array of coefficients (21+1). Use as main program the following code: #include #include "Polynomial.h" using namespace std; int main() { Polynomial A; cout << "Specify polynomial:" << endl; cin >> A; cout << "A = " << A << endl; double x; cout << "Specify value of x:" << endl; cin >> x; cout << "A(x) = " << A( x ) << endl; cout << "Indefinite integral of A = " << A.getIndefiniteIntegral() << endl; cout << "Differential of A = " << A.getDifferential() << endl; cout << "Differential of indefinite integral of A = " << A.getIndefiniteIntegral().getDifferential() << endl; cout << "Definite integral of A(xlow=0, xhigh=12.0) = " << A.getDefiniteIntegral( 0, 12.0 ) << endl; if ( A == A.getIndefiniteIntegral().getDifferential() ) { cout << "Polynomial operations are sound." << endl; } else { cout << "Polynomial operations are broken." << endl; } return 0; } Using -0.25x + 4.0 and 16 for the first calculation, the test code should produce the following result. COS30008 Semester 1, 2020 Dr. Markus Lumpe 5 The solution requires 40-60 lines of low density C++ code. Submission deadline: Monday, March 30, 2020, 12:30. Submission procedure: on paper, no electronic submissions, code of PolynomialPS1.

## Related Questions

##### . The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

##### . Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

##### . The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

##### . Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

##### . The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme  