# Java Program to Find Area of Equilateral Triangle

In the previous article we have discussed Java Program to Find Area of Isosceles Triangle

## Program to Find Area of Equilateral Triangle

Before jumping into the program directly, let’s first see how we calculate area of equilateral triangle.

Formula for Area of Equilateral Triangle: sqrt(3)/4)*(side*side)

Where,

• side‘ represents side length of the equilateral triangle.
• sqrt is the square root. (here square root of 3)

Let’s see different ways to do it.

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

### Method-1: Java Program to Find Area of Equilateral Triangle By Using Static Value

In this approach the side length of equilateral triangle is already defined in the program, which will be used to calculate the area based on the area calculation formula.

So, let’s see the program to understand it more clearly.

import java.util.*;

public class Main
{
public static void main(String args[])
{

//Side length of equilateral triangle is declared
double side= 5.6;
//calculating the area using the formula
double  area=(Math.sqrt(3)/4)*(side*side);
System.out.println("Area of Triangle : " + area);
}
}
Output:

Area of Triangle : 13.579278331339996

### Method-2: Java Program to Find Area of Equilateral Triangle By Using User Input Value

In this approach the side length of equilateral triangle will be taken as input from the user, which will be used to calculate the area based on the area calculation formula.

So, let’s see the program to understand it more clearly.

import java.util.*;

public class Main
{
public static void main(String args[])
{
//Scanner class Object Created
Scanner sc= new Scanner(System.in);
//Taking side length input of the triangle from the user
System.out.println("Enter side length of the triangle :");
double side= sc.nextDouble();
//calculating the area using the formula
double  area=(Math.sqrt(3)/4)*(side*side);
System.out.println("Area of Triangle : " + area);
}
}
Output:

Enter side length of the triangle : 5.6
Area of Triangle : 13.579278331339996

The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.

Related Java Programs: