Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following header file for polynomials -----------------------------

ID: 3775511 • Letter: C

Question

Complete the following header file for polynomials

---------------------------------------------------

//

// Agency.hpp

// Project07

//

// Created by Cody Goeken on 11/18/16.

// Copyright © 2016 Cody Goeken. All rights reserved.

//

#ifndef Agency_hpp

#define Agency_hpp

#include

#include

class Agency

{

  

public:

Agency();

Agency(int maxDegree, int* arrCoefficients);

Agency(const Agency& other);

~Agency();

  

int solve(int other);

Agency operator=(const Agency& poly);

bool operator==(const Agency& poly);

bool operator!=(const Agency& poly);

Agency operator+(const Agency& poly);

Agency operator-(const Agency& poly);

  

Agency operator*(const Agency& poly);

Agency operator*(int value);

  

  

  

//Friend Functions

friend std::ostream& operator<<(std::ostream& output, const Agency & poly);

friend std::istream& operator>>(std::istream& input, const Agency & poly);

  

//operator for freind functions << and >>

  

  

  

private:

int* coefficents;

int maxDegree;

  

bool isEqual(const Agency& poly);

Agency assign(const Agency& poly);

  

};

#endif /* Agency_hpp */

The following member function operators are required default constructor Initializes the degree to default size of 3 parameterized constructor Takes an integer representing the degree and an int* pointing to an array of coefficients and the constant copy constructor destructor solve Evaluates the polynomial at an integer (parameter) value and returns the result. As an example: x 2 when evaluated at 5 returns 27 operator Copies one polynomial to another operator Returns true if two polynomials are equal operator !J Returns true if two polynomials are not equal operator Multiplies together two polynomial expressions and returns a new polynomial of the product. This should work for polynomials of different sizes. As an example: (x 2x 1) (x 3) returns (x3 5x2 7x 3) operator Takes an integer parameter scalar and returns a new scaled polynomial. As an example: (x3 2x2 3x 4) 5 returns (5x3 10x2 15x 20) operator Takes two polynomials and adds their coefficients and returns a new polynomial of the sum. As an example: (x2 3x +1) (2x 2) returns (x2 x 1) operator Takes two polynomials and subtracts their coefficients and returns a new polynomial of the difference. As an example: (x 3x 1) (2x 2) returns (x 5x 3) The following friend function operators are required operator Outputs the polynomial to screen. It can be assumed that the variable being used is 'x'. An example output: xn3 3x 2. Do not print out any term with a zero coefficient operator Reads in from file the degree of the polynomial, then reads in all of the coefficients. See below for data file organization

Explanation / Answer

#ifndef POLYNOMIAL_H #define POLYNOMIAL_H #include using std::ostream; using std::istream; class Polynomial { public: Polynomial(); Polynomial( int degre, const double* clist ); Polynomial( const Polynomial& ); ~Polynomial(); int setDegree(int degre); int getDegree() const; const Polynomial& operator=( const Polynomial& clist); bool operator==( const Polynomial& clist) const; void printPolynomial( int dgr, const double* clist ); double operator[]( int index ) const; double& operator[]( int index ); private: int degree; double *coeff; // list of coefficients }; ostream& operator( istream& , Polynomial& ); #endif