Computer Science, asked by seacastrider2006, 8 months ago

Write a program in Java to find the area and perimeter of a right-
angled triangle by using function argument. Take perpendicular and
base as inputs.
angled triangle​

Answers

Answered by llɱissMaɠiciaŋll
20

Explanation:

hey here is ur answer:-

// Java Program to find Area of a Right Angled Triangle Example

package Area;

import java.util.Scanner;

public class AreaOfRightTriangle {

private static Scanner sc;

public static void main(String[] args) {

double width, height, c, Area, Perimeter;

sc = new Scanner(System.in);

System.out.println("\n Please Enter the Width of a Right Angled Triangle: ");

width = sc.nextDouble();

System.out.println("\n Please Enter the Height of a Right Angled Triangle: ");

height = sc.nextDouble();

Area = 0.5 * width * height;

c = Math.sqrt((width * width) + (height * height));

Perimeter = width + height + c;

System.out.format("\n The Area of a Right Angled Triangle = %.2f\n",Area);

System.out.format("\n The Other side of a Right Angled Triangle is: %.2f\n",c);

System.out.format("\n The Perimeter of a Right Angled Triangle = %.2f\n", Perimeter);

}

}

Answered by glory6341
4

Answer:

This is your Answer

Explanation:

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;

Similar questions