# Find the Area of a pentagon in Java …fcukthecode.com

Write a program that prompts the user to enter the length from the center of a pentagon to a vertex and computes the area of the pentagon, where r is the length from the center of a pentagon to a vertex.

(Hint: Length of the side =2*length from the center to a vertex * sine(PI/5)

Area = (5 * Math.pow(side, 2)) / (4 * Math.tan(Math.PI /5));

For rounding to two decimal points uses String.format(“%.02f”,variablename))

``````INPUT
6.4      // Length from the center of a pentagon to a vertex

OUTPUT
97.39    // Area of pentagon``````
```import java.io.*;
import java.util.*;
import java.lang.Math;
public class temp {
public static void main(String[] args) {
double length , side , area;
Scanner scan = new Scanner(System.in);
System.out.println("Enter the Length from the center of a pentagon to a vertex:  ");
length = scan.nextDouble();
side = 2 * length * Math.sin(Math.PI/5);
area = (5 * Math.pow(side,2)) / (4 * Math.tan(Math.PI/5));
System.out.println("Area of the pentagon:  "+String.format("%.02f",area));
}
}
```

INPUT_1:
Enter the Length from the center of a pentagon to a vertex:
6.4

OUTPUT:
Area of the pentagon:  97.39

INPUT_2:
Enter the Length from the center of a pentagon to a vertex:
5.9

OUTPUT:
Area of the pentagon:  82.77

INPUT_3:
Enter the Length from the center of a pentagon to a vertex:
7

OUTPUT:
Area of the pentagon:  116.50

INPUT_4:
Enter the Length from the center of a pentagon to a vertex:
5.2

OUTPUT:
Area of the pentagon:  64.29

INPUT_5:
Enter the Length from the center of a pentagon to a vertex:
10

OUTPUT:
Area of the pentagon:  237.76

ILLUSTRATION