Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please provide full answer with comments this is just begining course of c++ so don't use advanced tequenicks I'll put main.cpp, polynomial.h, polynomial.cpp and Cimg.h
please provide full answer with comments this is just begining course of c++ so don't use advanced tequenicks I'll put main.cpp, polynomial.h, polynomial.cpp and Cimg.h at the bottom of pictures. If you help me with this will be greatly thankful thank you
main.cpp
#include "polynomial.h" #include "polynomial.h" #include "polynomial.h" #include "polynomial.h" #includeusing std::cout; using std::endl; int main() { pic10a::polynomial p1; p1.setCoeff(0, 1.2); p1.setCoeff(3, 2.2); p1.setCoeff(7, -9.0); p1.setCoeff(7, 0.0); //degree of polynomial is now 3 cout polynomial.cpp
#include "polynomial.h" #include "CImg.h" #includestd::ostream& operator= 0; i--) { if (p.getCoeff(i) == 0) continue; if (i 0) s 1){ s 1 ? resolution : 5000; const unsigned int plot_type = cimg_option("-p", 1, "Plot type"); const unsigned int vertex_type = cimg_option("-v", 1, "Vertex type"); //Create plot data CImg values(1, nresolution, 1, 1, 0); const unsigned int r = nresolution - 1; for (int i1 = 0; i1 values2; values2 = values.display_graph(formula, plot_type, vertex_type, "X Axis", x0, x1, "Y Axis"); values.normalize(0, 255); values.save_bmp("plot.bmp"); } polynomial.h
#includeclass polynomial { public: polynomial(double c = 0.0); int degree(); int nonzeroTerms(); void setCoeff(int deg, double c); double getCoeff(int deg); double operator()(double x); polynomial operator+(polynomial p); polynomial& operator+=(polynomial p); polynomial operator-(); polynomial operator-(polynomial p); polynomial& operator-=(polynomial p); polynomial operator*(polynomial p); polynomial& operator*=(polynomial p); }; polynomial operator+(double c, polynomial p); polynomial operator*(double c, polynomial p); std::ostream& operator For Cimg.h this is the link it is too long i couldn't copy paste herehttp://www.math.ucla.edu/~eryu/courses/pic10a/hw/hw9/CImg.h
Download the starter code main. cpp, polynomial.h, polynomial.cpp, and CImg h. You will have to modify the header file but you may not change the signatures of the provided public methods of class polynomial. You are free to add any public and/or private members.) We have provided main.cpp to give you an idea of how we intend to use the functions. Put the implementations into the files polynomial. h and/or polynomial.cpp. All files you submit must not contain a main function You may not use global variables. You may not use the using-directive, using namespace std; You may not use #pragma once. You may not use any libraries aside from cassert, crnath, iostream, algorithm, vector, string, and CImg.h. We may take off up to 20 of the total marks for poor style; make sure to name your variables reasonably, indent properly, and comment sufficiently. Submit polynomial h and polynomial.cpp. In hw7 and hw8, we've forced you to put all function definitions into cpp files. However, there's nothing wrong with putting very short definitions into header files and putting only the long definitions into cpp files Problem 1: (Polynomial) Write a class that represents a polynomial The constructor pol y nom ial (double c 0.0); creates a polynomial that corresponds to p(a) The method int degree returns the degree of the polynomial. (For the purpose of this assignment, let's say the zero polynomial p(ar) 0 is degree 0. The method nonzero Terms int returns the number of nonzero terms of the polynomial. For example, 1 has 2 nonzero terms. The procedure void set Coeff int deg double c) sets the coefficient of the term deg to c. Calling this function can increase or decrease the degree of the polynomial. assert that deg is nonnegative The method
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started