Java Program to find the area of a pentagon

Program

import java.util.Scanner;
class AreaOfPentagon
{
	public static void main(String args[])
	{
		int apothem, side;
		float area, area_num;
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the apothem:\t");
		apothem = sc.nextInt();
		System.out.println("Enter the length of side:\t");
		side = sc.nextInt();
		area_num = (5 * side * apothem);
		area = area_num / 2;
		System.out.println("Area of pentagon: " + area);
	}
}

Output

Enter the apothem:	
7
Enter the length of side:	
10
Area of pentagon: 175.0

Tags: