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;

}```

2. what is the problem that you're having?

3. It says it failed to open the file lol cant even get it to do that. and also i doubt the above makes sense i completely guessed on a lot of it.
The file is saved as xydata.dat on my desktop

errors as follow:

'Project2.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Project2.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Project2.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
The program '[5024] Project2.exe: Native' has exited with code 0 (0x0).

4. those are debugger errors, and have nothing to do with the running of your program. check to see if it created the area.dat file. it should be in the Project2 folder or the Debug folder if it was created.

5. yeah it did but its completely blank

6. make sure that the input file is in the folder where the program is looking for it. it's likely that it's not the folder that the compiled exe is in. whatever folder the area.dat file was created in, that's where the input file needs to be.

7. thanks can u PLZ stick with me for 10 more mins maybe i can get this in on time!

here is the new output
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000
-737869781502640770.00000

8. I think you need to read in x1 and y1 before you start the while loop. read x2 and y2 at the top of the while loop and then at the bottom, copy x2 into x1 and copy y2 into y1.

9. still getting
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000
737869781502640770.00000

infinite amount of times - its an endless loop idk why

10. datain.eof() is not a good way to decide if you're done reading the file. use
Code:
`while (datain.good())`

11. now im just getting thearea under the curve is 0 lol...thanks for your help btw! cant explain how much i appreciate it. I think were close to getting it

12. post your latest code so I can have a look.

13. Code:
``` #include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

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

datain.open("xydata.dat");
infoout.open("area.dat");

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

while (datain.good())
{

datain>>x2;
datain>>y2;

area = 0.5*(x2-x1)*(y1+y2);

total = total + area;

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

x1=x2;
y1=y2;
}

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

}

else
{
cout<<"Error opening file"<<endl;
}
return 0;
system ("pause");
}```

14. why are you ignoring 80 characters at the beginning of the file? is it to ignore the first line? because there is a better way to do that. try using std::getline and a std::string.

also, try declaring x1, y1, x2, and y2 as double instead of int. that might help with some of your problem.

15. The area under the curve is "total" not "area". You are calculating the discrete sum correctly though: just add up the trapezoid areas. Even if you lose 10%, you can rest assured that while you need to learn more about programming, you are at least up to pace with mathematics; whereas many decent programmers understand an alarmingly small amount about math.