# Perimeter of parallelogram in java

Let’s learn perimeter of parallelogram in java.

## Perimeter of parallelogram in java

In the previous post we learnt area of parallelogram. Now let’s learn to calculate perimeter of parallelogram. As we know parallelogram shape opposite sides are equal. So formula to calculate perimeter of parallelogram is:

perimeter = 2(a + b)

where ‘a’ and ‘b’ are lengths of adjacent sides. Here’s the java program.

```import java.util.Scanner;
public class PerimeterOfParallelogram
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Please enter length of adjacent side of parallelogram: ");
double a = sc.nextDouble();
System.out.println("Please enter another length of adjacent side of parallelogram: ");
double b = sc.nextDouble();
double perimeter = 2 * (a + b);
System.out.println("perimeter of parallelogram is: " + perimeter);
sc.close();
}
}
```

Output:

Please enter length of adjacent side of parallelogram:
5
Please enter another length of adjacent side of parallelogram:
6
perimeter of parallelogram is: 22.0

Also read – switch statement in java