forked from cs-dept-ibbul/java2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab3Triangle.java
More file actions
61 lines (54 loc) · 1.24 KB
/
Copy pathLab3Triangle.java
File metadata and controls
61 lines (54 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
public class Triangle
{
int hypotenus;
int shortestSide;
int a;
int b;
int c;
public Triangle(int s1, int s2, int s3)
{
a = s1;
b = s2;
c = s3;
if (a > b && a > c)
{
hypotenus = a;
if (b > c)
shortestSide = c;
else if (c > b)
shortestSide = b;
}
else if (b > a && b > c)
{
hypotenus = b;
if (a > c)
shortestSide = c;
else if (c > a)
shortestSide = a;
}
else if (c > a && c > b)
{
hypotenus = c;
if (a > b)
shortestSide = b;
else if (b > a)
shortestSide = a;
}
}
public double getPerimeter()
{
double perimeter = a + b + c;
return perimeter;
}
public double getArea()
{
//using Heron's Formula
double s = (a + b + c)/2;
double area = Math.sqrt(s *((s-a) * (s-b) * (s-c)));
return area;
}
public double getRatio()
{
return hypotenus/shortestSide;
}
}