Write a program that enables the user to drag the vertices of a triangle and displays the
Question:
Write a program that enables the user to drag the vertices of a triangle and displays the angles dynamically as the triangle shape changes, as shown in Figure 15.30a. The formula to compute angles is given in Listing 4.1.
(a) Exercise enables the user to drag vertices and display the angles dynamically.
Listing
Transcribed Image Text:
101.93 34.53 43.54 (a) 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
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (7 reviews)
Program Plan The program creates a right angle triangle with the circles as points or as the vertice...View the full answer
Answered By
Anum Naz
Lecturer and researcher with 10+ years of experience teaching courses in both undergraduate and postgraduate levels. Supervised 17 BA theses, 07 MA theses, and 1 Ph.D. dissertations. Edited and co-authored 2 monographs on contemporary trends in political thought. Published over articles in peer-reviewed journals.
4.80+
11+ Reviews
51+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program that enables the user to enter text and displays the Huffman coding tree based on the text, as shown in Figure 25.25a. Display the weight of the subtree inside the subtree?s root...
-
Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays a line that connects the pair of nearest points, as shown in Figure 22.4. |...
-
Write a program that enables the user to add/remove points by clicking the left/right mouse button, and displays a noncrossed polygon that links all the points, as shown in Figure 22.11a. A polygon...
-
Transfer pricing is a significant area of concern for taxing authorities and multinational entities (MNE). Examine at least two (2) potential transfer pricing issues that create concern for both...
-
Show that the sequence of polynomials converges uniformly on any compact subset S . x2 2! 3! + k=0
-
In Problems 6568, assume that the minimum payment on a credit card is the greater of $20 or 2% of the unpaid balance. Find the minimum payment on an unpaid balance of $1,215.45.
-
Linda Budd went searching for a new friend and she found one for \($400.1\) A brand new puppy. She purchased the puppy from Bernadette Vicidomine, a person who regularly sells puppies. Budd took her...
-
Skaros Stairs Co. of Moore designs and builds factory-made premium wooden stairways for homes. The manufactured stairway components (spindles, risers, hangers, hand rails) permit installation of...
-
help me respond to this, Can I request a little insight on this zoom meetings attendees and the intended end result? Will this information conclusion be going back to the County auditors in a report?...
-
X Ltd. has 10 lakhs equity shares outstanding at the beginning of the accounting year 2016. The appropriate P/E ratio for the industry in which D Ltd. is 8.35. The earnings per share is Rs. 15 in 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...
-
Write a program that displays a circle of radius 10 pixels filled with a random color at a random location on a pane, as shown in Figure 15.29b. When you click the circle, it disappears and a new...
-
A city grew in population throughout the 1980s and into the early 1990s. The population was at its largest in 1995, and then shrank until 2010. Let P = f(t) represent the population of the city t...
-
Benedict is a partner in Sherlock Enterprises LLC. He contributed $400 of cash plus $1,100 worth of property that has an adjusted basis of $700. At the end of the year, his share of liabilities is...
-
In this problem, we are going to answer the following question. Given two points (1,1) and (2,2), can we find an exponential function y = c(a), such that it passes through both of these points? If...
-
Investor has zero basis stock with a FMV of $50 million. The investor buys a put with a strike price of $47,500,000. The taxpayer writes a call with a strike price of $60 million. The options expire...
-
Rose graduated last April from her part-time law degree at WSU. She was born in Malta and retains citizenship, but she has resided in Australia since she was five years old and worked various paid...
-
Joe has recently been admitted to the bar. Attorney Dan hires Joe as an Associate to supervise the work of Sally, the paralegal who has handled title searches in Dan's office for the last 10 years....
-
Sendelbach Corporation is a U.S.-based organization with operations throughout the world. One of its subsidiaries is headquartered in Toronto. Although this wholly owned company operates primarily in...
-
Following is the current balance sheet for a local partnership of doctors: The following questions represent independent situations: a. E is going to invest enough money in this partnership to...
-
Modify the CreditCard class from Code Fragment 1.5 to include a method that updates the credit limit.
-
Modify the CreditCard class from Code Fragment 1.5 so that it ignores any request to process a negative payment amount.
-
Modify the declaration of the first for loop in the main method in Code Fragment 1.6 so that its charges will cause exactly one of the three credit cards to attempt to go over its credit limit. Which...
-
A bond has a coupon rate of 1 0 . 5 % and pays coupons annually. The bond matures in 9 years and the yield to maturity on similar bonds is 9 . 4 % . What is the price of the bond?
-
A 1 5 - year, 1 4 % semiannual coupon bond with a par value of $ 1 , 0 0 0 may be called in 4 years at a call price of $ 1 , 0 7 5 . The bond sells for $ 1 , 0 5 0 . ( Assume that the bond has just...
-
A particle has its position as a function of time given by; (t) = 3.33m cos (0.95t+0.58) + 3.33m sin(0.95-t + 0.58) +5.82tk (The input below will accept answers with no more than 1% variation from...
Cellular And Molecular Toxicology And In Vitro Toxicology 1st Edition - ISBN: 1351367765 - Free Book
Study smarter with the SolutionInn App