Program to calculate length of hypotenuse of a right angle triangle given the value of base and height
Click here to download complete source code
import java.util.Scanner;
public class RightAngledTriangle
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double hypotenuse = 0;
double base = 0;
double height = 0;
System.out.print("Enter the value of base : ");
base = input.nextDouble();
System.out.print("Enter the value of height : ");
height = input.nextDouble();
hypotenuse = Math.sqrt(base * base + height * height);
System.out.println("");
System.out.println("The hypotenuse of right-angled triangle is :"
+ hypotenuse);
}
}
Output of the program :
