Check if right triangle possible from given area and hypotenuse | Java program to check existence of right triangle . ; Prints three sides of a right triangle from given area and hypotenuse if triangle is possible , else prints - 1. ; Descriminant of the equation ; applying the linear equation formula to find both the roots ; Driver code
class GFG { static void findRightAngle ( double A , double H ) { double D = Math . pow ( H , 4 ) - 16 * A * A ; if ( D >= 0 ) { double root1 = ( H * H + Math . sqrt ( D ) ) / 2 ; double root2 = ( H * H - Math . sqrt ( D ) ) / 2 ; double a = Math . sqrt ( root1 ) ; double b = Math . sqrt ( root2 ) ; if ( b >= a ) System . out . print ( a + " ▁ " + b + " ▁ " + H ) ; else System . out . print ( b + " ▁ " + a + " ▁ " + H ) ; } else System . out . print ( " - 1" ) ; } public static void main ( String arg [ ] ) { findRightAngle ( 6 , 5 ) ; } }