Whats wrong???
package com.codegym.task.task04.task0415;
/*
Rule of the triangle
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String S1 = reader.readLine();
int s1 = Integer.parseInt(S1);
String S2 = reader.readLine();
int s2 = Integer.parseInt(S2);
String S3 = reader.readLine();
int s3 = Integer.parseInt(S3);
if (s1<(s2+s3)||s2<(s1+s3)||s3<(s1+s2))
System.out.println("The triangle is possible.");
else
System.out.println("The triangle is not possible.");
}
}
Haelp anyone?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
8 May 2019, 14:55solution
use logical AND and not logical OR. A triangle can only exist in the case that each side is less than the sum of the other two sides. The above code will return the triangle being possible if only 1 side meets the 'less than' criteria.
+2
Jamp
8 May 2019, 17:44
Oh... Thank you kindly!
0