Find the length of the median of a Triangle if length of sides are given | Java program to find the length of the median using sides of the triangle ; Function to return the length of the median using sides of triangle ; Driver code ; Function call ; Print final answer with 2 digits after decimal
import java . util . * ; class GFG { public static float median ( int a , int b , int c ) { float n = ( float ) ( Math . sqrt ( 2 * b * b + 2 * c * c - a * a ) / 2 ) ; return n ; } public static void main ( String [ ] args ) { int a , b , c ; a = 4 ; b = 3 ; c = 5 ; float ans = median ( a , b , c ) ; System . out . println ( String . format ( " % .2f " , ans ) ) ; } }