your program cpp file of Task1 You can upload file several t
Solution
#include <iostream>
 #include <fstream>
 #include <Math.h>
 using namespace std;
 //make sure input file format and path of the file are clear
 //below is example file content
 /*
 x y
 a 1.2 3.6
 b 1.8 2.9
 c 3.6 5.7
 d 9.9 3.2
 */
 int main()
 {
 float cords[4][2],total=0,dist;
 char c,x,y;
 ifstream inData(\"week8triangle.txt\");
 inData >>x>>y; //read the first line to x and y chars
 for (int i=0; i<4; i++) {      
 inData >>c>> cords[i][0]>> cords[i][1];//Read x and y coordinates at position i into the array cords
 }
 inData.close();
 for (int i=1; i<4; i++) {      
 //caluclating sides and total
 dist=sqrt(pow((cords[i-1][0]-cords[i][0]),2)+pow((cords[i-1][1]-cords[1][0]),2));
  cout<<\"side \"<<i<<\":\"<<dist<<endl;
 total+=dist;
 }
 cout<<\"Total distance:\"<<total<<endl;
 return 0;
 }
//example output:-
side 1:1.89737
 side 2:2.1095
 side 3:7.40945
 Total distance:11.4163

