The folllowing program creaes a struct node and a struct triangle. A node will c
ID: 3682427 • Letter: T
Question
The folllowing program creaes a struct node and a struct triangle. A node will consist of the int values x and y reprsenting the x and y coordinates of the node. A triangle contains three nodes, three lenghts of the sides, and the tpe of the triangle(0: No triangle; 1: equilateral triangle; 2: isosceles; 3; scalene). constructTriangle function cretes a triangle from the three input nodes. The main function passes three input nodes to the construct Triangle, and then prints out the three edges and the type of the triangle. Finish the construct triangle function below
#include <iostream>
using namespace std;
struct Node { int x; int y};
struct triangle{ Node nodeA; Node nodeB; Node nodeC;double
edgeA; double edgeB;double edgeC; int type;};
Triangle constructTriangle{Node A, Node B, Node c};
void main()
{
Node nA,nB,nC;
cin>>nA.x >>nA.y;
cin>>nB.x >>nB.y;
cin>>nC.x >>nC.y;
Triangle tri;
tri=constructTriangle (nA,nB,nC);
cout<<"Edge 1: "<< tri.edgeA<<endl;
cout<<"Edge 2: "<< tri.edgeB<<endl;
cout<<"Edge 3: "<< tri.edgeC<<endl;
switch(tri.type)
{
case 0:
cout<<"No triangle"<<endl;
break;
case 1:
cout<<"This is an equilateral"<<endl;
break;
case 2:
cout<<"This is isosceles "<<endl;
break;
case 3:
cout<<"This is scalene"<<endl;
break;
}
}
Triangle constructTriangle (Node A,Node B, Node C){
}
//define a triangle
//assign values to three nodes
// calculate the threee edges
// check the triangle type
//0: No triangle; 1: equilateral triangle; 2: isosceles; 3; scalene
// return this triangle