package com.codegym.task.task04.task0415;
/*
Rule of the triangle
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
//write your code here
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
int c=in.nextInt();
if ((a+b<c)||(c+b<a)||(a+c<b)){
System.out.println("The triangle is not possible.");
}
else{
System.out.println("The triangle is possible.");
}
}
}

# Pretty sure my math is right

Resolved

Comments (1)

- Popular
- New
- Old

You must be signed in to leave a comment

Khurram

10 March 2019, 07:24solution

if a = 2 , b = 3 and c = 5
a + b = 5 which is equal to (but not greater than) c, the code will mention that the triangle is possible. However it is not. you need to consider the situation where sum of 2 sides is equal to the length of the 3rd side. The triangle should not be possible in such case.

+3