Q:

(Geometry: area of a pentagon) The area of a pentagon can be computed using the following formula:

0

(Geometry: area of a pentagon) The area of a pentagon can be computed using the following formula:

Write a method that returns the area of a pentagon using the following header:
public static double area(double side)

Write a main method that prompts the user to enter the side of a pentagon and displays its area. Here is a sample run:

 

Output:

Enter the side: 5.5
The area of the pentagon is 52.04444136781625

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

/*
(Geometry: area of a pentagon) The area of a pentagon can be computed using the
following formula:

					Area = (5 * s^2) / 4 * tan(PI / 5 )

Write a method that returns the area of a pentagon using the following header:
public static double area(double side)
Write a main method that prompts the user to enter the side of a pentagon and
displays its area.
*/
import java.util.Scanner;

public class Exercise_06_35 {
	/** Main Method */
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in); // Create a Scanner

		// Prompt the user to enter the side of a pentagon
		System.out.print("Enter the side: ");
		double side = input.nextDouble();

		// Display the pentagon's area
		System.out.println("The area of the pentagon is " + area(side));
	}

	/** Method area computes and returns the area of a pentagon */
	public static double area(double side) {
		return (5 * Math.pow(side, 2)) / (4 * Math.tan(Math.PI / 5));
	}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now