Question: LISTING 4.1 ComputeAngles.java 1 teport java.ut.Scanner 3 public class ComputeAngles ( 4public static void main(Stringtl args) Scanner input new Scanner (Systen.in): 1 Prompt the user

 LISTING 4.1 ComputeAngles.java 1 teport java.ut.Scanner 3 public class ComputeAngles (

LISTING 4.1 ComputeAngles.java 1 teport java.ut.Scanner 3 public class ComputeAngles ( 4public static void main(Stringtl args) Scanner input new Scanner (Systen.in): 1 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.nex t Double(); 12 double y2= input, nextDouble(); 13 double x3input.nextDouble(): 14 double y3 input. nextDouble) 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-P). (x1-x2) +(y1 y2) (y1-y2 23 24 1 Compute three angles 25 double A= Math.toDegrees (Hol?.7G0a( (a * a -b . b-c * c) 26 2 b c))): 27 double B = Math. toDegrees (Math, acos((b , b- a * a-c . c) 28 29 double C Math.toDegrees (Math.acos((c c b b - a a) 30 (2 a b)) 31 32 33 34 I Display results System.out.println("The three angles are"+ Math.round (A 100) 100.0"1 Math.round (B 100) I 100.0 + " " + Math.round (C 100) / 100.0); 36 37 38 Enter three points: 1 1 6.5 1 6.5 2.5Entr The three angles are 15.26 90.0 74.74 The program prompts the user to enter three points (line 8). This prompting message clear. You should give the user explicit instructions on how to enter these points as is not System.out print ("Enter the coordinates of three points separat + "by spaces 11ke x1 y1 x2 y2 x3 y3: ") Note that the distance between two points (x1, y1) and (x2, y2) can be compu the formula Vy). The program computes the distances be points (lines 17-22), and applies the formula to compute the angles (lines 25-30). uted using between two are rounded to display up to two digits after the decimal point (lines 34-36). The Math class is used in the program, but not imported, because it is in the java angles package. All the classes in the java. 1ang package are implicitly imported in a Java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!