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.
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the side: "); double lengthOfSide = input.nextDouble(); input.close(); double area = calculateArea(lengthOfSide); System.out.printf("The area of the pentagon is %.2f", area); } private static double calculateArea(double s) { double area = (5 * s * s) / (4 * Math.tan(Math.PI / 5)); return area; }
Enter the side: 5.5 The area of the pentagon is 52.04