0

I am having problem with calculating the angle using sin. So far, I got the literal of numbers, which is not making sense.

I am supposed to match my answers with this:

Set up new triangle with coordinates (0.0, 0.0), (3.0, 0.0), (3.0, 4.0)

Area: 6.0

Parimeter: 12.0

Length side a: 4.0

Length side b: 5.0

Length side c: 3.0

Angle A: 53.13010235415598

Angle B: 90.0

Angle C: 36.86989764584402

Height: 4.0

But I got this:

Set up new triangle with coordinates (0.0,0.0), {3.0,0.0), (3.0,4.0)

Area: 6.0

Parameter: 12.0

Length side a: 4.0

Length side b: 5.0

Length side c: 3.0

Angle A: 0.9272952180016123

Angle B: 1.5707963267948966

Angle C: 0.6435011087932843

Height: 4.0

Where do I go wrong?

Test Class

```
import javax.swing.JOptionPane;
public class TriangleTester
{
public static void main(String args[])
{
/*Initializes the variables.
Getting the coordinates from the user
*/
double xPointA = Double.parseDouble(JOptionPane.showInputDialog("Enter x1 for point A:"));
double yPointAB = Double.parseDouble(JOptionPane.showInputDialog("Enter y1 for point A and B:"));
double x2PointB = Double.parseDouble(JOptionPane.showInputDialog("Enter x2 for point B:"));
double x3PointC = Double.parseDouble(JOptionPane.showInputDialog("Enter x3 for point C:"));
double y2PointC = Double.parseDouble(JOptionPane.showInputDialog("Enter y2 for point C:"));
//Creating an object
Triangle math = new Triangle();
math.calcLength(xPointA,yPointAB,x2PointB,yPointAB,x3PointC,y2PointC);
math.calcParameter();
math.calcArea(y2PointC);
System.out.println("Set up new triangle with coordinates (" + xPointA + "," + yPointAB + "), {"
+ x2PointB + "," + yPointAB + "), (" + x3PointC + "," + y2PointC + ")");
System.out.println("Area: " + math.getArea());
System.out.println("Parameter: " + math.getParimeter());
System.out.println("Length side a: " + math.getLengthA());
System.out.println("Length side b: " + math.getLengthB());
System.out.println("Length side c: " + math.getLengthC());
System.out.println("Angle A: " + math.getAngleA());
System.out.println("Angle B: " + math.getAngleB());
System.out.println("Angle C: " + math.getAngleC());
System.out.print("Height: " + y2PointC);
}
}
```

Functional Class

```
import java.lang.Math;
public class Triangle
{
//Insti
double area;
double lengthA;
double lengthB;
double lengthC;
double angleA;
double angleB;
double angleC;
double paraNum;
public void calcLength(double Ax, double Ay, double Bx, double By, double Cx, double Cy)
{
lengthA = (Math.pow((Cx - Bx),2) + Math.pow((Cy -By), 2));
lengthA = Math.sqrt(lengthA);
lengthB = (Math.pow((Cx - Ax),2) + Math.pow((Cy -Ay), 2));
lengthB = Math.sqrt(lengthB);
lengthC = (Math.pow((Bx - Ax),2) + Math.pow((By -Ay), 2));
lengthC = Math.sqrt(lengthC);
}
//Calculate the area with the parameter of height.
public void calcArea(double height)
{
area = (lengthC * height);
area = area / 2;
}
public void calcParameter()
{
paraNum = lengthA + lengthB + lengthC;
}
public double getParimeter()
{
return paraNum;
}
public double getLengthA()
{
return lengthA;
}
public double getLengthB()
{
return lengthB;
}
public double getLengthC()
{
return lengthC;
}
public double getAngleA()
{
angleA = Math.acos((lengthB*lengthB + lengthC*lengthC - lengthA*lengthA) / (2*lengthB*lengthC));
return angleA;
}
public double getAngleB()
{
angleB = Math.acos((lengthA*lengthA + lengthC*lengthC - lengthB*lengthB) / (2*lengthA*lengthC));
return angleB;
}
public double getAngleC()
{
angleC = Math.acos((lengthB*lengthB + lengthA*lengthA - lengthC*lengthC) / (2*lengthB*lengthA));
return angleC;
}
public double getArea()
{
return area;
}
}
```