Tuesday, March 18, 2008

length of the hypotenuse of a right triangle

/* Program to computes the length of the hypotenuse of a right triangle */

class P12
{
public static void main(String args[])
{
double a = 3.0, b= 4.0;
double c = Math.sqrt(a*a+b*b);
System.out.println(" Hypotenuse is :"+c);
}
}

2 comments:

Unknown said...

import java.util.Scanner;

public class Test{
public static void main(String args[]){
Double side1,side2,hypotenuse;

Scanner s=new Scanner(System.in);
System.out.println("Enter two sides");
side1=s.nextDouble();
side2=s.nextDouble();
System.out.println(side1 + " " +side2);

hypotenuse=Math.sqrt(side1 * side1 + side2+side2);
System.out.println("Hypotenuse = " + hypotenuse);


}


}

Unknown said...
This comment has been removed by the author.