Output

Variable     Value
x1
y1
x2
y2
x3
y3
a
b
c
A
B
C
  1  import java.util.Scanner;
  2  
  3  public class ComputeAngles {
  4    public static void main(String[] args) {
  5      Scanner input = new Scanner(System.in);
  6      
  7      // Prompt the user to enter three points
  8      System.out.print("Enter three points: ");
  9      double x1 = input.nextDouble();
 10      double y1 = input.nextDouble();
 11      double x2 = input.nextDouble();
 12      double y2 = input.nextDouble();
 13      double x3 = input.nextDouble();
 14      double y3 = input.nextDouble();
 15      
 16      // Compute three sides
 17      double a = Math.sqrt((x2 - x3) * (x2 - x3) 
 18        + (y2 - y3) * (y2 - y3));
 19      double b = Math.sqrt((x1 - x3) * (x1 - x3) 
 20        + (y1 - y3) * (y1 - y3));
 21      double c = Math.sqrt((x1 - x2) * (x1 - x2) 
 22        + (y1 - y2) * (y1 - y2));
 23      
 24      // Compute three angles
 25      double A = Math.toDegrees(Math.acos((a * a - b * b - c * c) 
 26        / (-2 * b * c)));
 27      double B = Math.toDegrees(Math.acos((b * b - a * a - c * c) 
 28        / (-2 * a * c)));
 29      double C = Math.toDegrees(Math.acos((c * c - b * b - a * a) 
 30        / (-2 * a * b)));
 31      
 32      // Display results
 33      System.out.println("The three angles are " + 
 34        Math.round(A * 100) / 100.0 + " " +
 35        Math.round(B * 100) / 100.0 + " " + 
 36        Math.round(C * 100) / 100.0);
 37    }
 38  }