In this coursework you are not allowed to change the name of

In this coursework, you are not allowed to change the name of input file. In the marking, we change the numbers in the input file so that do not calculate the solutions manually and report these. You are not allowed to use file output. You program should just read the input file and display the solutions. You should use Visual Studio 2015. If you did not follow these instructions, you will be penalized. Write 3 programs and upload each program (cpp file) to Blackboard (Go to Blackboard 16/17-EN2008 Coursework. For instance, to upload the program of Task1, click CW1Task1 then click Browse My Computer and upload your program cpp file) of Task1. You can upload file several times for each question. But we mark only the latest attempt. If you have questions on the coursework, please raise in the next lab session. Task1 [6 points] Create a program that reads coordinates of four points (A, B, C and D) in 2D from the file (week8triangle.txt) and reports the user the followings: 1: Each length of sides of the triangle of points A, B and C 2: Total length of sides of the triangle Task2 [7 points] Based on the program of Q1 (use the same input file), create a program that reports 1: Angles of A, B and C In degrees 2: Area of the triangle

Solution

#include<iostream>
#include<conio.h>
#include<math.h>

#define PI 3.14159265;

using namespace std;

double Distance(double a1, double b1, double a2, double b2)
{
double a, b, distance;
x = a2 - a1;
y = b2 - b1;
dst = pow(a,2) + pow(b,2);
dst = sqrt(dst);
return dst;
}

double otherAngleFind(double bg_A, double l_d, double s_d)
{
double o_a;
o_a = s_d *sin(b_a*3.14159265/180);
o_a = o_a/l_a;
o_a = asin(o_a)*180.0 / PI;
return o_a;
}


double BiggerAngleFind(double l_d, double s_d, double s_D_2)
{
double b_a;
b_a = pow(s_d,2) + pow(s_d_2, 2) - pow(l_d,2);
b_a = fabs(b_a/(2*s_d*s_d_2));
b_a = acos(b_a)* 180.0 / PI;
return b_a;
}


void TriangleAngleCalculation(double x1, double y1, double x2, double y2, double x3, double y3)
{
double d1, d2, d3;
double g1, g2, g3;
double ttl;

int lL = 0;
d1 = DistanceTwoPoints(a1, b1, a2, b2);
d2 = DistanceTwoPoints(a2, b2, a3, b3);
d3 = DistanceTwoPoints(a1, b1, a3, b3);

cout<<\"Distance\"<<d1<<\" \"<<d2<<\" \"<<d3;

if(d1>d2 && d1 > d3)
{
//cout<<\"distance1 is greater\";
g1 = BiggerAngleFind(d1, d2, d3);
g2 = otherAngleFind(g1, d1, d2);
g3 = otherAngleFind(g1, d1, d3);

//g2 = OtherAngleFind(g1, d1, d2);

ttl=g1+g2+g3;

if(ttl <180)
{
g1 = 180 - g1;
}
}
else if(d2 > d3 && d2 > d1)
{
// cout<<\"distance 2 is greater\";
g2 = BiggerAngleFind(d2, d1, d3);
g1 = otherAngleFind(g2, d2, d1);
g3 = otherAngleFind(g2, d2, d3);

ttl=g1+g2+g3;

if(ttl <180)
{
g2 = 180 -g2;
}
}
else
{
// cout<<\"distance 3 is greater\";
g3 = BiggerAngleFind(d3, d1, d2);
g1 = otherAngleFind(g3, d3, d2);
g2 = otherAngleFind(g3, d3, d2);

ttl=g1+g2+g3;

if(ttl <180)
{
g3 = 180 - g3;
}
}

cout<<endl<<\"Angle Between First Point and Second Point = \"<<g3<<endl;
cout<<\"Angle Between First Point and Third Point = \"<<g2<<endl;
cout<<\"Angle Between Second Point and Third Point = \"<<g1<<endl;
}


int main()
{
double a1, b1, a2, b2, a3, b3;
cout<<\"Enter a   cordinate value of first coordinate in the triangle = \";
cin>>a1;
cout<<\"Enter b   cordinate value of first coordinate in the triangle = \";
cin>>b1;
cout<<\"Enter a   cordinate value of second coordinate in the triangle = \";
cin>>a2;
cout<<\"Enter b   cordinate value of second coordinate in the triangle = \";
cin>>b2;
cout<<\"Enter a   cordinate value of third coordinate of triangle = \";
cin>>a3;
cout<<\"Enter b cordinate value of third coordinate of triangle = \";
cin>>b3;

cout<<endl<<\" Point1 of a triangle is (\"<<a1<<\" , \"<<b1<<\")\"<<endl;
cout<<\"Point2of a triangle is is (\"<<a2<<\" , \"<<b2<<\")\"<<endl;
cout<<\" Point3 of a triangle is is (\"<<a3<<\" , \"<<b3<<\")\"<<endl;

TriangleAngleCalculation(a1, b1, a2, b2, a3, b3);

getch();
}

 In this coursework, you are not allowed to change the name of input file. In the marking, we change the numbers in the input file so that do not calculate the
 In this coursework, you are not allowed to change the name of input file. In the marking, we change the numbers in the input file so that do not calculate the
 In this coursework, you are not allowed to change the name of input file. In the marking, we change the numbers in the input file so that do not calculate the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site