Question: DesignProject - 2 - In this design project, you will write a program that calculates the area under the curve of a polynomial function. The
DesignProjectIn this design project, you will write a program that calculates the area under the curve of
a polynomial function. The user provides the polynomials coefficients, and the program
returns the approximate value of the area.
#include
#include
#include
#include
#include
using namespace std;
const double XMIN ;
const double XMAX ;
const double TOL ;
prettyprint polynomial
void printpolynomialvector c
double ci;
bool flag true;
cout px;
forunsigned long int i csize; i ; i
ci cati; current coefficient
if csize cout ci; always print at least one coefficient
if ci
Print signs. Only print first sign if it is negative.
if flag
handle first minus sign
flag false;
if ci cout ;
else
if ci cout ;
else cout ;
Print coefficient
if i
cout absci; always print last coefficient
else if absci
cout absci; don't print ones
Print x except for last coefficient
if i
cout x;
Print exponent, except for last two coefficients
if i
cout i;
cout endl;
evaluate polynomial given by coefficients c at x
double evaldouble x vector c
your code here
exact theoretical area
double exactvector c
vector cint; coefficients of integral
cint.pushback; integral of polynomial has no zerodegree term
for unsigned long int i ; i csize; i
cint.pushbackcatii; integrate termbyterm
return evalXMAX cint evalXMIN cint; fundamental theorem of calculus
read coefficients from cin, until empty newline
vector readcoefficientsvoid
your code here
double estimatedouble step, vector c
your code here
int mainvoid
your code here
return ;
ie if the Input is:
the output will be
Solution:
pxxxx
Estimate
Exact
Error
Iterations
Step
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
