Java Program to Find Area of Isosceles Triangle
import java.util.*;
public class Main
{
// finding the altitude
static float altitude(float s1, float s2)
{
// returning altitude
return (float)(Math.sqrt(Math.pow(s1, 2) - (Math.pow(s2, 2) / 4)));
}
// finding area
static float area(float s2, float h)
{
// returning area
return (1 * s2 * h) / 2;
}
// Driver Code
public static void main(String[] args)
{
float s1 = 2, s2 = 3;
float h = altitude(s1, s2);
System.out.println("Altitude= " + h );
float a = area(s2, h);
System.out.print("Area= " + a );
}
}
Output:
Altitude Isosceles triangle = 1.3228756
Area of Isosceles triangle = 1.9843135
