Array-promo

Question

Program to calculate the perimeter of the square.

Share code with your friends

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

Code

				
					import java.util.Scanner;
public class perimeterOfSquare
{  
    public static void main(String args[])  
    {  
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a length of square");
        double a=sc.nextDouble();
        
        /*Formula of perimeter of square =4*(length of square)*/
        double perimeter=4*a;  
        System.out.println("perimeter of square="+perimeter);  
     }  
}  

				
			

Coding Store

Leave a Reply

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