Length of diagonal of a parallelogram using adjacent sides and angle between them | Java program to find length Of diagonal of a parallelogram Using sides and angle between them . ; Function to return the length Of diagonal of a parallelogram using sides and angle between them . ; Driver Code ; Given sides ; Given angle ; Function call ; Print the final answer
class GFG { static double Length_Diagonal ( int a , int b , double theta ) { double diagonal = Math . sqrt ( ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) ) - 2 * a * b * Math . cos ( theta * ( Math . PI / 180 ) ) ) ; return diagonal ; } public static void main ( String [ ] args ) { int a = 3 ; int b = 5 ; double theta = 45 ; double ans = Length_Diagonal ( a , b , theta ) ; System . out . printf ( " % .2f " , ans ) ; } }