text: Maximize volume of cuboid with given sum of sides | Java code to Maximize volume of cuboid with given sum of sides ; Return the maximum volume . ; for length ; for breadth ; for height ; calculating maximum volume . ; Driver function
code: class GFG { static int maxvolume ( int s ) { int maxvalue = 0 ; for ( int i = 1 ; i <= s - 2 ; i ++ ) { for ( int j = 1 ; j <= s - 1 ; j ++ ) { int k = s - i - j ; maxvalue = Math . max ( maxvalue , i * j * k ) ; } } return maxvalue ; } public static void main ( String [ ] args ) { int s = 8 ; System . out . println ( maxvolume ( s ) ) ; } }