Java Program to Find Perimeter of a Rhombus

Write a Java Program to Find the Perimeter of a Rhombus with an example. This example allows to enter the rhombus side, and the area is four times the side.

import java.util.Scanner;

public class PerimeterOfRhombus1 {
	private static Scanner sc;

	public static void main(String[] args) {
		double rhomside, rhomPerim;
		sc = new Scanner(System.in);
		
		System.out.print("Please Enter Rhombus Side = ");
		rhomside = sc.nextDouble();

		rhomPerim =  4 * rhomside; 
		System.out.format("The Perimeter of a Rhombus = %.2f\n", rhomPerim);
	}
}
Java Program to find Perimeter of a Rhombus 1

In this Program, we created a function that returns the Rhombus perimeter.

import java.util.Scanner;

public class PerimeterOfRhombus2 {
	private static Scanner sc;

	public static void main(String[] args) {
		float rhomside, rhomPerim;
		sc = new Scanner(System.in);
		
		System.out.print("Please Enter Side = ");
		rhomside = sc.nextFloat();

		rhomPerim =  rhombusPerimeter(rhomside); 

		System.out.format("The Perimeter = %.2f", rhomPerim);
	}
	
	public static float rhombusPerimeter(float rhomside) {
		return 4 * rhomside; 
	}
}
Please Enter Side = 13
The Perimeter = 52.00

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.