Find maximum volume of a cuboid from the given perimeter and area | function to return maximum volume ; calculate length ; calculate volume ; return result ; Driver code ; Function call
function maxVol ( P , A ) { let l = ( P - Math . sqrt ( P * P - 24 * A ) ) / 12 ; let V = l * ( A / 2.0 - l * ( P / 4.0 - l ) ) ; return V ; } let P = 20 , A = 16 ; document . write ( maxVol ( P , A ) . toFixed ( 5 ) ) ;