Olivia likes triangles. Hence, John decided to give her three integers and ask whether a triangle with edge length as given three integers is possible.
Help Olivia in answering it.
Input
The input consists of a single line containing three space-separated integers A, B, and C.
Constraints
1 <= A, B, C <= 100
Output
Output “Yes” if the triangle is possible otherwise, “No” (without quotes).
Example
Sample Input 1:
5 3 4
Sample Output 1:
Yes
Sample Explanation 1:
The possible triangle is a right-angled triangle with a hypotenuse of 5.
Solution
import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework
// don't change the name of this class
// you can add inner classes if needed
class Main {
public static void main (String[] args) {
// Your code here
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if (a + b > c && a + c > b && b + c > a) {
System.out.println("Yes");
// sauravhathi
} else {
System.out.println("No");
}
}
}
Happy Learning – If you require any further information, feel free to contact me.