I've been looking for help on this for few hours now and can't find anything or maybe I'm just not looking in the right places.
I'm trying to create a simple program in Java wich takes three positve integers as command-line-argument and prints TRUE if any one of them is greater or equal to the sum of the other two and FALSE otherwise.
public class Triangle {
public static void main(String[] args){
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
boolean isTriangle;
isTriangle = (a + b >= c);
isTriangle = (b + c >= a);
isTriangle = (a + c >= b);
System.out.println(isTriangle);
}
}
Hope some of could maybe give me an answer or something that points me in the right direction so I can get this right.
public class Triangle {
public static void main(String[] args){
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
boolean isTriangle;
isTriangle = (a + b >= c) || (b + c >= a) || (a + c >= b);
System.out.println(isTriangle);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With