-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtria.java
More file actions
28 lines (19 loc) · 844 Bytes
/
tria.java
File metadata and controls
28 lines (19 loc) · 844 Bytes
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
package time;
import java.util.Scanner;
public class tria {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the length of the first edge: ");
double edge1 = sc.nextDouble();
System.out.print("Enter the length of the second edge: ");
double edge2 = sc.nextDouble();
System.out.print("Enter the length of the third edge: ");
double edge3 = sc.nextDouble();
if (edge1 + edge2 > edge3 && edge1 + edge3 > edge2 && edge2 + edge3 > edge1) {
double perimeter = edge1 + edge2 + edge3;
System.out.println("Perimeter of the triangle is: " + perimeter);
} else {
System.out.println("Invalid input. The given sides do not form a valid triangle.");
}
}
}