//******************************************************************** // hypotenuse.java // // Demonstrates the use of the Math class to perform a calculation // based on user input. //******************************************************************** import java.util.Scanner; public class hypotenuse { //----------------------------------------------------------------- // Determines the roots of a quadratic equation. //----------------------------------------------------------------- public static void main (String[] args) { int side1, side2; double squaredsum, hypot; Scanner scan = new Scanner(System.in); System.out.print ("Enter the length of the first leg of the right triangle: "); side1 = scan.nextInt(); System.out.println (side1); System.out.print ("Enter the length of the second leg of the right triangle: "); side2 = scan.nextInt(); System.out.println (side2); // Determine the sum of the squares of the two sides squaredsum = Math.pow(side1, 2) + Math.pow(side2, 2); // Take the square root of the squared sum to get the length of the hypotenuse hypot = Math.sqrt(squaredsum); System.out.println ("Length of hypotenuse is " + hypot); } }