int main()
{
ofstream fout;//opens output file
fout.open("Output.txt");//designates output file
if(fout.fail())
{
cerr << "output file failed to open" <<endl;
}
///this section just deals with user input of variables to be manipulated
double left = 0, right = 0, usertol, tol = 0, permaRight =0;
cout << "Please enter left lateral limit." << endl;
//cin >> left;
left = 0; //testing conditions
fout << "Left limit is " << left << endl;
cout << "Left limit is " << left << endl;
cout << "Please enter right lateral limit." <<endl;
//cin >> right;
right = 4; ///testing conditions
permaRight = right;// will keep the right limit stored for the recursive function to check against
fout << "Right limit is " << right << endl;
cout << "Right limit is " << right << endl;
cout << "Please enter area accuracy tolerance." <<endl;
//cin >> usertol;
usertol = .1;
tol = usertol/2; ///testing conditions
fout << "Tolerance within " << tol <<endl;
cout << "Tolerance within " << tol <<endl;
double F(double x)
{
double z;
z = pow(x,3)+2;
return z;
}
double midpoint(double a, double b, int c)
{
double z;
z=(a+b)/(pow((double)2,c));
return(z);
}
double funcArea(double a, double b, double midpoint, double limit)
{
double z;
z =((a+b)/2)*(fabs(midpoint - limit)); // a = f(right or left limit) b= f(midpoint)
//fabs = absolute value of the midpoint
//limit could be left or right the absolute value function will allow it to work with either
return z;
}
Bookmarks