Java Program to Calculate Area of Square

You are currently viewing Java Program to Calculate Area of Square

In this article, You will learn the concept of the Java Program to Calculate Area of Square. Firstly, We will talk about an area of a square and what are the possibilities to perform a task using the java program? Let’s start the article.

Area Of Square

The area of a square is nothing but the measure of the space or surface occupied by it. It is equal to the product of the length of its two sides.

The formula for calculating an area of a square will show below for your reference.

area = width × height
Area of square will be calculated as : 
area = side²
since width = height; 

Java Program to Calculate Area of Square

This is the example program to execute a task here.

public class shpere{      
    public static void main(String args[])  
    {  
    int s=15;  
   int area_square=s*s;  
        System.out.println("Area of the square="+area_square);  
     }  
}

Source Code Execution

Initially, We need to declare the respective variable to store the length of a square. The area of a square will be calculated by applying the length value into the formula directly after executing this program. The calculated output will display on the screen using the system.out.printIn() function.

Read Also : Java Program to Calculate Find Area Of Square

Note

We have already posted the article about Find Area of Square Using PHP on our webpage. Please refer to learn about it.

Output of Java Program to Calculate Area of Square

The reference output will be given below. Please check it.

Area of the square=225

Final Thoughts

I hope this article helps you to Find the Area of Square using the Java Program. If you face any issues please let me know via the comment section. Share this article with other Java program developers via social networks. Thank You!

Manoj S

Hi, I'm Manoj working as a part-time blogger in Coding Diksha. Here, I post about programming to help developers.

Leave a Reply