google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Write a program to accept perpendicular and base of a right angled triangle. Calculate and display hypotenuse, area and perimeter of the triangle.

Write a program to accept perpendicular and base of a right angled triangle. Calculate and display hypotenuse, area and perimeter of the triangle.

1

import java io*;

public class Triangle
{
public static void main (String args[]) throws IOException
{
int p.b;
double h,ar,pm;
InputStreamReader read=new InputStreamReader(System.in)
BufferedReader in = new BufferedReader (read);
System.out.println("Enter perpendicular and base of the triangle");

p=Interger.parseInt(in.readLine());
b=Interger.parseInt(in.readLine());
h=Math.sqrt(p*p+b*b);
ar=1.0/2.0*p*b;
pm=(p+b+h);

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

System.out.println("Area of the triangle="+ar);

System.out.println("Perimeter of the Triangle="+pm);
}
}

Expected output:

Enter perpendicular and base of the triangle
10
24
Hypotenuse of the Triangle=26.0;
Area of the Triangle=120.0;
Perimeter of the Triangle=60.0;

Post a Comment

1 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top