/* 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);
}
}
Subscribe to:
Post Comments (Atom)
2 comments:
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);
}
}
Post a Comment