Answer to Question #3903 in Java | JSP | JSF for Jon

Question #3903
Write a program called TriangleChecker that has the following specification:

a. Accept three command line arguments that can give integer data values. These arguments represent the lengths if the sides of a triangle.

b.Check whether the 3 values can be the sides of a triangle. A triangle will not be possible if the sum of any two is less than or equal to the third.
1
Expert's answer
2011-08-07T07:25:13-0400
import java.util.*;public class TriangleChecker {
public static boolean check(int a, int b, int c) {
if (((a + b) <= c) || ((a + c) <= b) || ((c + b) <= a))
return false;
else
return true;
}

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int side_a;
int side_b;
int side_c;
System.out.println("Enter side a");
side_a = scan.nextInt();
System.out.println("Enter side b");
side_b = scan.nextInt();
System.out.println("Enter side c");
side_c = scan.nextInt();
System.out.println(check(side_a, side_b, side_c));

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS