Implement a class Triangle. A Triangle is defined by the x- and y- coordinates of its three corner points. Your job is to compute the following properties of a given triangle: • the lengths of all sides (methods getsidelLength, getSide2Length, getside 3Length) the angles at all corners (methods getAnglel, getAngle2, getAngle3) • the perimeter (the getPerimeter method) • the area (the getArea method) Implement a Triangle class using the template provided here: Triangle.java Example: Triangle triangle new Triangle (0, 5, 1.5, 2, 8, 25.92); triangle.getSidelLength (); // 3.3541019662496847 triangle.getSide2Length (); // 22.39746414217467 triangle.getSide3Length (); // 24.787424230847385 triangle.getAnglel (); // 2.312694531902217 triangle.getAngle2 (); // 0.7289796952097912 triangle.getAngle3 (); // 0.09991842647778622 triangle.getPerimeter (); // 50.53899033927174 triangle. getArea () ; // 27.690000000000044

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java. Please follow the template in the picture, thank you!

30 /**
* A class to represent a triangle defined by the x- and y-coorindates of its
* three corner points
4
7 public class Triangle {
8
9.
// ADD YOUR INSTANCE VARIABLES HERE
10
110
/**
12
* Constructs a triangle with the given corner points
*
13
* @param x1 x-value of corner point 1
* @param y1 y-value of corner point 1
* @param x2 x-value of corner point 2
* @param y2 y-value of corner point 2
* @param x3 x-value of corner point 3
* @param y3 y-value of corner point 3
*/
14
15
16
17
18
19
20
public Triangle(double x1, double y1, double x2, double y2, double x3, double y3) {
// FILL IN
}
210
22
23
24
25
260
/**
27
* Returns the length of side 1: (x1, y1) to (x2, y2)
*
28
@return the length of side 1
*/
*
29
30
public double getSide1Length() {
return -1.0; // FIX ME
}
310
32
33
34
35
**
360
37
* Returns the length of side 2: (x1, y1) to (x3, y3)
*
38
* @return the length of side 2
*/
39
40
public double getSide2Length() {
return -1.0; // FIX ME
410
42
43
}
44
45
460
/**
47
* Returns the length of side 3: (x2, y2) to (x3, y3)
48
@return the length of side 3
*/
public double getSide3Length() {
return -1.0; // FIX ME
}
49
50
510
52
53
54
55
560
/**
57
* Returns the angle at corner 1 (x1, y1)
58
* @return the angle at corner 1
*/
59
60
public double getAngle1() {
return -1.0; // FIX ME
}
610
62
63
64
65
/**
* Returns the angle at corner 2 (x2, y2)
660
67
68
*
@return the angle at corner 2
*/
69
70
public double getAngle2() {
return -1.0; // FIX ME
}
710
72
73
74
75
760
/**
77
* Returns the angle at corner 3 (x3, y3)
78
*
@return the angle at corner 3
* /
79
80
public double getAngle3() {
return -1.0; // FIX ME
}
810
82
83
84
85
860
/**
87
* Returns the perimeter of the triangle
88
@return the perimeter of the triangle
*/
89
90
public double getPerimeter() {
return -1.0; // FIX ME
}
910
92
93
94
95
960
/**
97
Returns the area of the triangle
*
98
*
@return the area of the triangle
*/
99
L00
L010
public double getArea() {
return -1.0; // FIX ME
}
L02
L03
L04 }
Transcribed Image Text:30 /** * A class to represent a triangle defined by the x- and y-coorindates of its * three corner points 4 7 public class Triangle { 8 9. // ADD YOUR INSTANCE VARIABLES HERE 10 110 /** 12 * Constructs a triangle with the given corner points * 13 * @param x1 x-value of corner point 1 * @param y1 y-value of corner point 1 * @param x2 x-value of corner point 2 * @param y2 y-value of corner point 2 * @param x3 x-value of corner point 3 * @param y3 y-value of corner point 3 */ 14 15 16 17 18 19 20 public Triangle(double x1, double y1, double x2, double y2, double x3, double y3) { // FILL IN } 210 22 23 24 25 260 /** 27 * Returns the length of side 1: (x1, y1) to (x2, y2) * 28 @return the length of side 1 */ * 29 30 public double getSide1Length() { return -1.0; // FIX ME } 310 32 33 34 35 ** 360 37 * Returns the length of side 2: (x1, y1) to (x3, y3) * 38 * @return the length of side 2 */ 39 40 public double getSide2Length() { return -1.0; // FIX ME 410 42 43 } 44 45 460 /** 47 * Returns the length of side 3: (x2, y2) to (x3, y3) 48 @return the length of side 3 */ public double getSide3Length() { return -1.0; // FIX ME } 49 50 510 52 53 54 55 560 /** 57 * Returns the angle at corner 1 (x1, y1) 58 * @return the angle at corner 1 */ 59 60 public double getAngle1() { return -1.0; // FIX ME } 610 62 63 64 65 /** * Returns the angle at corner 2 (x2, y2) 660 67 68 * @return the angle at corner 2 */ 69 70 public double getAngle2() { return -1.0; // FIX ME } 710 72 73 74 75 760 /** 77 * Returns the angle at corner 3 (x3, y3) 78 * @return the angle at corner 3 * / 79 80 public double getAngle3() { return -1.0; // FIX ME } 810 82 83 84 85 860 /** 87 * Returns the perimeter of the triangle 88 @return the perimeter of the triangle */ 89 90 public double getPerimeter() { return -1.0; // FIX ME } 910 92 93 94 95 960 /** 97 Returns the area of the triangle * 98 * @return the area of the triangle */ 99 L00 L010 public double getArea() { return -1.0; // FIX ME } L02 L03 L04 }
Implement a class Triangle. A Triangle is defined by the x- and y- coordinates of its three corner
points.
Your job is to compute the following properties of a given triangle:
the lengths of all sides (methods getSidelLength, getSide2Length, getSide3Length)
• the angles at all corners (methods getAnglel, getAngle2, getAngle3)
• the perimeter (the getPerimeter method)
• the area (the getArea method)
Implement a Triangle class using the template provided here: Triangle.java
Example:
Triangle triangle = new Triangle (0, 5, 1.5, 2, 8, 25.92);
triangle.getSidelLength(); // 3.3541019662496847
triangle.getSide2Length (); // 22.39746414217467
triangle.getSide3Length (); // 24.787424230847385
triangle.getAnglel (); // 2.312694531902217
triangle.getAngle2 (); // 0.7289796952097912
triangle.getAngle3 (); // 0.09991842647778622
triangle.getPerimeter(); // 50.53899033927174
triangle.getArea (); // 27.690000000000044
Transcribed Image Text:Implement a class Triangle. A Triangle is defined by the x- and y- coordinates of its three corner points. Your job is to compute the following properties of a given triangle: the lengths of all sides (methods getSidelLength, getSide2Length, getSide3Length) • the angles at all corners (methods getAnglel, getAngle2, getAngle3) • the perimeter (the getPerimeter method) • the area (the getArea method) Implement a Triangle class using the template provided here: Triangle.java Example: Triangle triangle = new Triangle (0, 5, 1.5, 2, 8, 25.92); triangle.getSidelLength(); // 3.3541019662496847 triangle.getSide2Length (); // 22.39746414217467 triangle.getSide3Length (); // 24.787424230847385 triangle.getAnglel (); // 2.312694531902217 triangle.getAngle2 (); // 0.7289796952097912 triangle.getAngle3 (); // 0.09991842647778622 triangle.getPerimeter(); // 50.53899033927174 triangle.getArea (); // 27.690000000000044
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education