Question: Draw a circle with three random points on the circle. Connect the points to form a triangle. Display the angles in the triangle. Use the
Draw a circle with three random points on the circle. Connect the points to form a triangle. Display the angles in the triangle. Use the mouse to drag a point along the perimeter of the circle. As you drag it, the triangle and angles are redisplayed dynamically, as shown in Figure 15.30b. For computing angles in a triangle, see Listing 4.1.
Listing
![{ 4 public static void main(String[] args) { 5 Scanner input =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a7346efd46_710636a7346df9f4.jpg)

83.37 S1.07 45.56 (b) 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 // Prompt the user to enter three points System.out.print("Enter three points: "); double x1 = input.nextDouble(); double yl = input.nextDouble(); double x2 = input.nextDouble(); double y2 = input.nextDouble(); double x3 = input.nextDouble(); double y3 = input.nextDouble(); 8. 9. 10 11 12 13 14 15 16 17 18 19 20 21 22 // Compute three sides double a = Math.sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3)); double b Math.sqrt((x1 - x3) * (x1 - x3) + (yl - y3) * (yl - y3)); double c - + (yl - y2) * (yl - y2)); Math.sqrt((x1 - x2) (1 - 2) 23 // Compute three angles double A = 24 Math.toDegrees (Math.acos ((a / (-2 * b * c))); double B = Math.toDegrees (Math.acos((b / (-2 * a * c))); double C = Math.toDegrees (Math.acos((c * c - b * b - a * a) / (-2 * a * b))); 25 26 27 c) 28 29 30 31 // Display results System.out.println("The three angles are Math.round(A * 100) / 100.0 + " " + 32 33 34 NNNN NNNN NNM mmmm
Step by Step Solution
3.48 Rating (168 Votes )
There are 3 Steps involved in it
Program Plan The program is designed to create a circle with three random points on the circumferenc... View full answer
Get step-by-step solutions from verified subject matter experts
