-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidtriangle.java
More file actions
22 lines (20 loc) · 935 Bytes
/
Copy pathvalidtriangle.java
File metadata and controls
22 lines (20 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner; // import statement for Scanner class
public class validtriangle { // class defination
public static void main(String[] args) {
Scanner input = new Scanner(System.in); // Scanner class object create
System.out.println("Enter value of Angle 1st");
int ang1 = input.nextInt(); // taking integer input
System.out.println("Enter value of Angle 2nd");
int ang2 = input.nextInt();
System.out.println("Enter value of Angle 3rd");
int ang3 = input.nextInt();
int triangle = ang1 + ang2 + ang3;
// condition for a triangle - the sum of 3 angles should be equal to 180 degree
if(triangle == 180){
System.out.println("This is a Triangle which angles are "+ang1+","+ang2+","+ang3);
}
else{
System.out.println("This combination of angles does not make a valid triangle");
}
}
}