Need help 10% of grade due in 50 min. Pay $10

If you can help me with this I will take ur address and mail you $10. It is extremely urgent...havent had time to do it because of pledging.
I need to calculate area under a curve using provided x and y coordinates which are to be opened from a document called xydata.dat. Here is the data as written in the document:

x values y values
20.00 0
20.02 15
20.04 27
20.06 39
20.08 54
20.10 65
20.12 75
20.14 84
20.16 93
20.18 101
20.20 108
20.22 113
20.24 116
20.26 115
20.28 112
20.30 107
20.32 100
20.34 92
20.36 83
20.38 74
20.40 64
20.42 53
20.44 39
20.46 27
20.48 15
20.50 0

Here is the best ive done so far but its wrong but I was never taught this in depth


/*Program to take x and y values from a curve and add up the area of the
trapezoids they form.
input:x values and y values from document
processing: 0.5(x1 – x2)(f(x2) + f(x3)) + 0.5(x3 – x2)(f(x2) + f(x3))+....
output: area under the curve (sum of all trapezoids)
*/

#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

int main()
{
ifstream datain;
ofstream infoout;
int x1,y1,x2,y2;
double area;
double total;

datain.open("xydata.dat"); //opening file for input
infoout.open("area.dat"); //opening file for output

if (!datain.fail())
{
datain.ignore(80,'\n');
datain>>x1;
datain>>y1;
datain>>x2;
datain>>y2;

while (!datain.eof())
{
area = 0.5*(x1-x2)*(y1+y2);

infoout<<setw(6)<<fixed<<setprecision(5)<<area<<endl;

datain>>x1;
datain>>y1;
datain>>x2;
datain>>y2;
total = total + area;
}

infoout<<"\nThe area under the curve is "<<area;


}

else
{
cout<<"Error opening file"<<endl;
}
return 0;
}
lol...

People aren't going to just do your homework for you, and trying to bribe people makes it worse.
Last edited on
Sorry mate- looks like time is up..
Topic archived. No new replies allowed.