Computer Science, asked by advithi157, 5 hours ago

Write a program in Java to calculate and display the hypotenuse of a Right-Angled Triangle by taking perpendicular and base as inputs. Hint: h = √p 2 + b 2​

Answers

Answered by Aravinthan31
11

Answer:

import java.util.Scanner;

public class KboatHypotenuse

{

   public static void main(String args[]) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter Perpendicular: ");

       double p = in.nextDouble();

       System.out.print("Enter Base: ");

       double b = in.nextDouble();

       

       double h = Math.sqrt(Math.pow(p, 2) + Math.pow(b, 2));

       

       System.out.println("Hypotenuse = " + h);

Answered by biswalabhishikta61
1

Answer:

import java.util.Scanner;

class KboatHypotenuse

{

public static void main ( )

{

Scanner sc= new Scanner (System.in);

System. out. println ("Enter Perpendicular") ;

double p= sc. next Double ( ) ;

System. out. println ("Enter Base")

double b=sc.next Double ( ) ;

double h= Math sqrt (Math.pow(p.2)) +

(Math pow(b.2))

System. out. println("Hypotenuse+h") ;

}

}

Similar questions