Repository: TheAlgorithms/Java
Pull request #3247 (2022-09-02 17:17:34)

Perimeter Calculator
I went through the Maths section of the repository and found programs for volume and area but not perimeter. So this is a program to calculate perimeter of geometrical objects.

- [x] Add an algorithm?

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized.
- [x] All functions and variable names follow Java naming conventions.

poorvadiwan: I have completed the changes you asked!! 
I apologize for the mess, actually, I am new to GitHub so I was a bit confused.

Patch:
diff --git a/pom.xml b/pom.xml
index b3ddcc5d..9840532e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>17</maven.compiler.source>
         <maven.compiler.target>17</maven.compiler.target>
-        <assertj.version>3.22.0</assertj.version>
+        <assertj.version>3.23.1</assertj.version>
     </properties>
 
     <dependencyManagement>
@@ -31,6 +31,7 @@
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter</artifactId>
+            <version>5.9.0</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -38,6 +39,12 @@
             <artifactId>assertj-core</artifactId>
             <version>${assertj.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>5.9.0</version>
+            <scope>import</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/com/thealgorithms/maths/Perimeter.java b/src/main/java/com/thealgorithms/maths/Perimeter.java
new file mode 100644
index 00000000..046b9b29
--- /dev/null
+++ b/src/main/java/com/thealgorithms/maths/Perimeter.java
@@ -0,0 +1,38 @@
+package com.thealgorithms.maths;
+
+public class Perimeter {
+    public static void main(String[] args) {
+        System.out.println(perimeter_polygon(5,4));
+        System.out.println(perimeter_rectangle(3,4));
+        System.out.printf("%,3f",circumference(5));
+    }
+    // Perimeter of different 2D geometrical shapes
+    /**
+     *Calculate the Perimeter of polygon.
+     * @parameter length of side.
+     * @parameter number of sides.
+     * @return Perimeter of given polygon
+     */
+    public static float perimeter_polygon( int n, float side){
+        float perimeter = n*side;
+        return perimeter;
+    }
+    /**
+     *Calculate the Perimeter of rectangle.
+     * @parameter length and breadth.
+     * @return Perimeter of given rectangle
+     */
+    public static float perimeter_rectangle( float length, float breadth){
+        float perimeter = 2*(length + breadth);
+        return perimeter;
+    }
+    /**
+     *Calculate the circumference of circle.
+     * @parameter radius of circle.
+     * @return circumference of given circle.
+     */
+    public static double circumference( float r){
+        double circumference = 2*Math.PI*r;
+        return circumference;
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/maths/perimeterTest.java b/src/test/java/com/thealgorithms/maths/perimeterTest.java
new file mode 100644
index 00000000..bbb228d8
--- /dev/null
+++ b/src/test/java/com/thealgorithms/maths/perimeterTest.java
@@ -0,0 +1,37 @@
+package com.thealgorithms.maths;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class perimeterTest {
+
+    //Perimeter of polygon
+    @Test
+    void testcase1(){
+        Assertions.assertEquals(20.0,Perimeter.perimeter_polygon(4,5));
+    }
+    @Test
+    void testcase2(){
+        Assertions.assertEquals(30.0,Perimeter.perimeter_polygon(5,6));
+    }
+
+    //Perimeter of Rectangle
+    @Test
+    void testcase3(){
+        Assertions.assertEquals(18.0,Perimeter.perimeter_rectangle(4,5));
+    }
+    @Test
+    void testcase4(){
+        Assertions.assertEquals(14.0,Perimeter.perimeter_rectangle(4,3));
+    }
+
+    //Circumference of a circle
+    @Test
+    void testcase5(){
+        Assertions.assertEquals(31.41592653589793,Perimeter.circumference(5));
+    }
+    @Test
+    void testcase6(){
+        Assertions.assertEquals(43.982297150257104,Perimeter.circumference(7));
+    }
+}