Java Program to Find the Perimeter of a Rectangle

0

 


A shape is called a rectangle when the opposite sides are equal. If in a rectangle all four sides are equal then it is called a Square.

To calculated the perimeter of a rectangle we have to sum total length of all its four sides.

Perimeter of rectangle ABCD = A+B+C+D

But since opposite sides are equal then A=C and B=D

hence our formula will be 2A+2B= 2(A+B)



import java.io.*;
class HindiCodingCommunity {
static void perimeter(int length, int breath)
{
int perimeter = 2 * (length + breath);
System.out.println("The perimeter is "+perimeter);
}
public static void main(String[] args)
{
int length = 5;
int breath = 8;
perimeter(length, breadth);
}
}



Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !