Pin It

How to calculate length of hypotenuse of a right angle triangle given the value of base and height in Java ?

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 : 
  
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot