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:
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);