Java Program to Calculate the Length of Hypotenuse

bookmark

import java.io.*;
class Main
{
    public static void main(String [] args)
    {
        double p = 3;
        double b = 4;   
        // formula to find hypotenuse 
        double h =  Math.sqrt((p*p)+(b*b)); 
        System.out.println("The hypotenuse is: " + h);
    }
}

 


Output:

The hypotenuse is: 5.0