# Java Program to find Area Of Equilateral Triangle

• Write a Java program to find the area of an equilateral triangle.

To find the area of an equilateral triangle, we need the length of any side of triangle. Before discussing about how to find the area of equilateral triangle, here is the brief summary of equilateral triangle.

• The length of all three sides of an equilateral triangle are equal.
• All three internal angles of equilateral triangle are equal and measures 60 degree.
How to Find Area of Equilateral Triangle ?
The area of an equilateral triangle is the amount of two-dimensional space inside it. If we know the length of any side of equilateral triangle, then we can use following formulae to calculate it's area.
Area of Equilateral Triangle = (√ 3 /4)S2
Where, S is the length of each side of triangle.

## Java Program to Find Area of an Equilateral Triangle

In this java program, we first take an integer input from user as the length of sides of equilateral triangle and store it in variable side. Then we calculate the area of given equilateral triangle using above mentioned formulae.

```package com.tcc.java.programs;

import java.util.Scanner;

/**
* Java Program to find area of an equilateral triangle
*/
public class AreaOfEquilateralTriangle {

public static void main(String[] args) {
double side, area;
Scanner scanner;
scanner = new Scanner(System.in);
// Take input from user
System.out.println("Enter Length of Side of an Equilateral Triangle");
side = scanner.nextDouble();

/*
* Area of equilateral triangle = sqrt(3)/4 x Side x Side
*/
area = Math.sqrt(3) / 4 * side * side;

System.out.format("The Area of Equilateral Triangle = %.3f\n", area);
}
}
```
Output
```Enter Length of Side of an Equilateral Triangle
6
The Area of Equilateral Triangle = 15.588
```

## Java Program to Find the Perimeter of Equilateral Triangle

Perimeter of equilateral triangle is the sum of the length of all three sides of the triangle. As we know, that all sides of equilateral triangles are equal, hence it's perimeter is equal to three times the length of any side of triangle.

```package com.tcc.java.programs;

import java.util.Scanner;

/**
* Java Program to find perimeter of an equilateral triangle
*/
public class PerimeterOfEquilateralTriangle {

public static void main(String[] args) {
double side, perimeter;
Scanner scanner;
scanner = new Scanner(System.in);
// Take input from user
System.out.println("Enter Length of Side of an Equilateral Triangle");
side = scanner.nextDouble();

/* Perimeter of equilateral triangle = 3 X Side */
perimeter = 3 * side;

System.out.format("The Perimeter of Equilateral Triangle = %.3f\n", perimeter);
}
}
```
Output
```Enter Length of Side of an Equilateral Triangle
6
The Perimeter of Equilateral Triangle = 18.000
```

Recommended Posts
 Java Program to Find Area Of Triangle Java Program to Find Area of Right Angled Triangle Java Program to Find Area Of Trapezoid Java Program to calculate area and circumference of circle Java Program to Calculate Volume of Sphere Java Program to Calculate Surface Area and Volume of Cube Java Program to Find Surface Area and Volume of Cylinder Java Program to Calculate Volume and Surface Area of Cone Java Program to Print Pascal Triangle Java Program to Print Right Triangle Star Pattern Java Program to Print Pyramid Pattern of Stars All Java Programs
 Previous Next