Java Program to Calculate Area Of Rectangle

You are currently viewing Java Program to Calculate Area Of Rectangle

Hello reader! Are you looking to learn Java Program to Calculate Area Of Rectangle? If yes then refer to this tutorial. Yes, I’m going to talk about an area of a rectangle and how to perform a task using the java program? here.

Area Of Rectangle

The area of a rectangle is the region occupied by a rectangle within its four sides or boundaries. The area of a rectangle depends on its sides.

Basically, the formula for area is equal to the product of length and breadth of the rectangle. This is the formula that will be given below:

A= W x H

Here, “A” is an area, “W” is width, and “H” is height.

Java Program to Calculate Area Of Rectangle

We can see the example Java Program to Calculate Area Of Rectangle below:

public class rectangle{  
    public static void main(String args[])  
    {  
    int width=6;  
    int height=8;  
    int area=width*height;  
        System.out.println("Area of rectangle="+area);  
     }  
} 

Execution of Program

Initially, We need to provide the values of the width and the height of a rectangle into this program. Later, We will apply the values into the formula directly to calculate the area of a rectangle after executing this program. Finally, We will see the output on the screen using the system.out.printIn() function.

Read Also : Java Program to Calculate Find Area Of Circle

Note

If you want to Find Area of Rectangle in JavaScript and Find Area of Rectangle in PHP then please read those articles on our web portal which we have already shared.

Output

Below, You will see the reference output of the java program to calculate area of rectangle.

Area of rectangle=48

Final Words

I believe this report about the area of a rectangle in Java will beneficial to you. Is this program useful for you? then give your powerful feedback about it. Do share this knowledge with other Java developers.

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