-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComputeAngles.java
63 lines (23 loc) · 933 Bytes
/
ComputeAngles.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class ComputeAngles {
public static void main(String[]args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter three points: ");
double x1 = input.nextDouble();
double y1 = input.nextDouble();
double x2 = input.nextDouble();
double y2 = input.nextDouble();
double x3 = input.nextDouble();
double y3 = input.nextDouble();
double a = Math.sqrt((x2 - x3) * (x2 - x3)
+ (y2 - y3) * (y2 - y3));
double b = Math.sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
double c = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
double A = Math.toDegrees(Math.acos((a * a - b * b - c * c ) / (-2 * b * c)));
double B = Math.toDegrees(Math.acos((b * b - a * a - c * c)
/ (-2 * a * c)));
double C = Math.toDegrees(Math.acos((c * c - b * b - a * a)
/ (-2 * a * b)));
System.out.println("The three angles are " + Math.round(A * 100) / 100.0);
}
}