I need to write a JavaScript program that allows a user to input three integers using textboxes in a form.(also i'll need to use the built-in parseInt function to convert the input strings to integers.) Test the three integers to determine if they can be formed into a triangle using the rule given above. Also test if the resulting triangle would be a right triangle using the Pythagorean theorem, namely that the square of the hypotenuse (the longest side) equals the sum of squares of the other two sides. Display an alert box to inform the user whether their integers can form a triangle or a right triangle (tell them which), or if the integers cannot form a triangle. Continue accepting sets of three integers and testing them until the user decides to quit.
Explanation / Answer
class Echo{ public static void main (String [] args) throws java.io.IOException { Scanner console = new Scanner(System.in); Integer s1; Integer s2; Integer s3; System.out.print("Enter the length of the first side of the triangle: "); s1 = Integer.parseInt(console.next()); System.out.print("Enter the length of the second side of the triangle: "); s2 = Integer.parseInt(console.next()); System.out.print("Enter the length of the third side of the triangle: "); s3 = Integer.parseInt(console.next()); if (s1 + s2