Let’s learn perimeter of rhombus in java.
Perimeter of Rhombus in java
In my previous post we learnt area of rhombus. We all know sides of a rhombus are all equal.
Opposite sides of rhombus are parallel to each other and opposite angles of rhombus are equal to each other. Now to calculate perimeter of rhombus here’s the formula
P = 4 * a
where ‘a’ is four sides of rhombus. Here’s the java program.
import java.util.Scanner; public class PerimeterOfRhombus { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Please enter side of rhombus: "); double side = sc.nextDouble(); double perimeter = 4 * side; System.out.println("Perimeter of Rhombus is: " + perimeter); sc.close(); } }
Output:
Please enter side of rhombus: 5
Perimeter of Rhombus is: 20.0
Also read – access modifiers in java