area of equilateral triangle in java

Let’s learn area of equilateral triangle in java.

area of equilateral triangle in java

An equilateral triangle is geometrical shape where its three sides are equal.

Formula to calculate area of equilateral traingle is –

area of equilateral triangle: √3/4 x s²

where ‘s’ is side of equilateral triangle.

Here’s the java program.

import java.util.Scanner;
public class AreaOfEquilateral
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter the side of equilateral triangle: ");
      double side = sc.nextDouble();
      double area = (Math.sqrt(3)/4) * (side * side);
      System.out.println("Area of equilateral triangle is: " + area);
      sc.close();
   }
}


Output:

Please enter the side of equilateral triangle:
6
Area of equilateral triangle is: 15.588457268119894


Also read – java program to calculate area of rectangle