Array-promo

Question

Program to calculate the area of the square.

				
					lets assume, length of one side of square is 10.Then,
Area of square=length of one side of square*length of one side of square
Area of square=10*10=100

Enter length of square
12
Area of square=144.0
				
			

Share code with your friends

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

Code

				
					import java.util.Scanner;
public class areaOfSquare
{  
    public static void main(String args[])  
    {  
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter length of square");
        double len=sc.nextDouble();
        
        /*Formula of area of square =length of square ^ 2 or(length of square * length of square )*/
        double area=len*len;  
        System.out.println("Area of square="+area);  
     }  
}  

				
			

Coding Store

Leave a Reply

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