seriously if you could help me i wil be in debt to you forever. 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 writtten 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 rudimentary and i just dont know where to go next

Code:

/*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=0;
datain.open("xydata.dat");
infoout.open("area.dat");
if (!datain.fail())
{
datain.ignore(80,'\n');
while (!datain.eof())
{
datain>>x1;
datain>>y1;
datain>>x2;
datain>>y2;
area = 0.5*(x1-x2)*(y1+y2);
infoout<<setw(6)<<fixed<<setprecision(5)<<area<<endl;
total = total + area;
}
infoout<<"\nThe area under the curve is "<<area;
}
else
{
cout<<"Error opening file"<<endl;
}
return 0;
}