How to find perimeter of rhombus – Java Program to Find Perimeter of Rhombus

How to find perimeter of rhombus: In the previous article we have discussed Java Program to Find Area of Rhombus

In this article we will discuss about how to find perimeter of rhombus.

Program to Find Perimeter of Rhombus

How to find perimeter of a rhombus: Before jumping into the program directly, let’s first see how we calculate perimeter of rhombus.

Formula for Perimeter of Parallelogram : 4a

Where,

  • a‘ represents side length of rhombus.
  • Side length of rhombus are equal in nature.

Example:

Example- To find Perimeter of Rhombus

When length of each side of Rhombus = 4
Then Perimeter of square => Perimeter = 4*sideLength
                                          => Perimeter = 4*4
                                          => Perimeter = 16

Let’s see different ways to do it.

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list is mandatory.

Method-1: Java Program to Find Perimeter of Rhombus By Using Static Value

How to find the perimeter of rhombus: Let’s see the program to understand it more clearly.

import java.util.*;

public class Main

{
    public static void main(String args[]) 
    {   
         //Side length of Rhombus declared
         double sideLength= 4.5;
         //finding perimeter
         double  p=4*sideLength;
      
     System.out.println("Perimeter of Rhombus : " + p);      
    }
}
Output:

Enter side length of Rhombus: 4.4
Perimeter of Rhombus : 17.6

Method-2: Java Program to Find Perimeter of Rhombus By User Input Value

How to find the perimeter of a rhombus: Let’s see the program to understand it more clearly.

import java.util.*;

public class Main

{
    public static void main(String args[]) 
    {   
         //Scanner class object created
      	 Scanner sc= new Scanner(System.in);
         //Taking side length of rhombus as input from user
         System.out.println("Enter side length of Rhombus:");
         double sideLength= sc.nextDouble();
         //finding perimeter
         double  p=4*sideLength;
      
     System.out.println("Perimeter of Rhombus : " + p);      
    }
}
Output:

Enter side length of Rhombus: 4.4
Perimeter of Rhombus : 17.6

Method-3: Java Program to Find Perimeter of Rhombus By User Defined Method

Find the perimeter of a rhombus: Let’s see the program to understand it more clearly.

import java.util.*;

public class Main

{
    public static void main(String args[]) 
    {   
         //Scanner class object created
      	 Scanner sc= new Scanner(System.in);
         //Taking side length of rhombus as input from user
         System.out.println("Enter side length of Rhombus:");
         double sideLength= sc.nextDouble();
         //findPerimeter() method called
         findPerimeter(sideLength);
    }
    
    //user defined method
    //findPerimeter() method to find perimeter of rhombus
    public static void findPerimeter(double sideLength)
    {
         //finding perimeter
         double  p=4*sideLength;
      
     System.out.println("Perimeter of Rhombus : " + p);      
    }
}
Output:

Enter side length of Rhombus: 4.4
Perimeter of Rhombus : 17.6

Access the Simple Java program for Interview examples with output from our page and impress
your interviewer panel with your coding skills.

Related Java Programs:

Leave a Comment