Array-promo

Question

program to find the area of a regular pentagon.

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					import java.util.Scanner;
public class areaOfRegularPentagon
{  
    public static void main(String args[])  
    {      
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the apothem length of regular pentagon");
        double a=sc.nextDouble();
        System.out.println("Enter the  length of one side of regular pentagon");
        double s=sc.nextDouble();
        /*area of regular pentagon=(5*length of one side of regular pentagon*apothem length)/2*/
        double area=(float)(5.0/2.0)*s*a;  
        System.out.println("Area of the pentagon="+area);  
     }  
} 

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *