Let’s learn java program to find perimeter of a rectangle.

## Java program to find perimeter of a rectangle

In perimeter of rectangle java program user enters length and width of a rectangle. Then using the formula to find perimeter of rectangle,

perimeter = 2 * (length + width). Lastly print the perimeter value.

Also read – string concatenation in java

For example,

Input:

Length = 10

Width = 5

Perimeter = 2 * (10 + 5) = 30

Here’s program to find the perimeter of the rectangle,

// rectangle java program import java.util.Scanner; public class PerimeterOfRectangleDemo { public static void main(String []args) { int length, width, perimeter; Scanner sc = new Scanner(System.in); System.out.print("Enter length of rectangle : "); length = sc.nextFloat(); System.out.print("Enter width of rectangle : "); width = sc.nextFloat(); perimeter = 2 * (length + width); System.out.println("Perimeter of rectangle : " + perimeter); sc.close(); } }

**Output:**

Enter length of rectangle : 2

Enter width of rectangle : 5

Perimeter of rectangle : 14