Given the length of 3 sides of a triangle, check whether the triangle is valid or not.
Input Format
First and only line of input contains three integers A, B, C – length of sides of the triangle.
Constraints
1 <= A, B, C <= 109
Output Format
Print “Yes” if you can construct a triangle with the given three sides, “No” otherwise.
Inputcopy | Outputcopy |
---|---|
4 3 5 | Yes |
Explanation 0
Self Explanatory
Solutions:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
long val1=sc.nextLong();
long val2=sc.nextLong();
long val3=sc.nextLong();
if(val1 + val2 > val3 && val2 + val3 > val1 && val1 + val3 > val2) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}