In this post we are going to learn java program to find perimeter of a rectangle.

#### Java program to find perimeter of a rectangle

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

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

Also read – calculate area of rectangle in java

For example,

Input:

Length = 10

Width = 5

Perimeter = 2 * (10 + 5) = 30

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

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