Length of a Diagonal of a Parallelogram using the length of Sides and the other Diagonal | Java Program to implement the above approach ; Function to calculate the length of the diagonal of a parallelogram using two sides and other diagonal ; Driver Code ; Function Call ; Print the final answer
class GFG { static float Length_Diagonal ( int a , int b , int d ) { float diagonal = ( float ) Math . sqrt ( 2 * ( ( a * a ) + ( b * b ) ) - ( d * d ) ) ; return diagonal ; } public static void main ( String [ ] args ) { int A = 10 ; int B = 30 ; int D = 20 ; float ans = Length_Diagonal ( A , B , D ) ; System . out . printf ( " % .1f " , ans ) ; } }