Sunday, 12 March 2023

5. Write a program to calculate the hypotenuse of right angled triangle when other sides of the triangle are given. (Hypotenuse = square root (x*x + Y *Y))

 



import java.util.*;

class Program5
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
       
        System.out.print("\nenter value for x: ");
        double x = sc.nextInt();
       
        System.out.print("\nenter value for y: ");
        double y = sc.nextInt();
       
        double h = Math.sqrt((x*x) + (y*y));
       
        System.out.print("\nHypotenuse of right angled triangle is: " + h);
    }
}


No comments:

Post a Comment

python programs

1. sum of two number