-1

I'm having trouble with a program to calculate a triangles area using fstream. The problem is I need the program to open the function to calculate the area in a file ("project3_1.dat") and to read in another file with coordinates of triangles. I wrote what I could in my program but now I'm stuck. Any help could do. Thanks.

```
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<cmath>
double main()
{
using namespace std;
ifstream in_stream;
ofstream out_stream;
in_stream.open("project3_1.dat");
if(in_stream.fail())
{
cout<<"Input file opening failed.\n";
exit(1);
}
out_stream.open("result3_1.dat");
if(out_stream.fail())
{
cout<<"Output file opening failed.\n";
exit(1);
}
double x_1,y_1,x_2,y_2,x_3,y_3,i,a,b,c,area;
i=0;
while (i<5)
in_stream>>x_1>>y_1>>x_2>>y_2>>x_3>>y_3;
out_stream<<"The area of the points in project3_1.dat is\n"
<<(a= sqrt(pow(x_1-x_2,2)+pow(y_1-y_2,2)));
b= sqrt(pow(x_2-x_3,2)+pow(y_2-y_3,2));
c= sqrt(pow(x_3-x_1,2)+pow(y_3-y_1,2));
if (area>0)
{ cout<<"The area of your triangle is\n"<<area<<endl;
}
else
cout<<"The points you have entered lie on the same line\n";
return 0;
}
double triangle_area (double a, double b, double c)
{
double result,s,i;
s= (a+b+c)/2.0;
result= sqrt(s*(s-a)*(s-b)*(s-c));
i=i+1;
}
in_stream.;close();
out_stream;.close();
return,
}
```