Program to calculate area and perimeter of a rhombus whose diagonals are given | Java program to calculate area and perimeter of a rhombus using diagonals ; calculate area and perimeter of a rhombus ; Driver code
import java . io . * ; class GFG { static int rhombusAreaPeri ( int d1 , int d2 ) { int area , perimeter ; area = ( d1 * d2 ) / 2 ; perimeter = ( int ) ( 2 * Math . sqrt ( Math . pow ( d1 , 2 ) + Math . pow ( d2 , 2 ) ) ) ; System . out . println ( " The ▁ area ▁ of ▁ rhombus ▁ with ▁ diagonals ▁ " + d1 + " ▁ and ▁ " + d2 + " ▁ is ▁ " + area + " . " ) ; System . out . println ( " The ▁ perimeter ▁ of ▁ rhombus ▁ with ▁ diagonals ▁ " + d1 + " ▁ and ▁ " + d2 + " ▁ is ▁ " + perimeter + " . " ) ; return 0 ; } public static void main ( String [ ] args ) { int d1 = 2 , d2 = 4 ; rhombusAreaPeri ( d1 , d2 ) ; } }