Largest cube that can be inscribed within a right circular cylinder | Java Program to find the biggest cube inscribed within a right circular cylinder ; Function to find the volume of the cube ; height and radius cannot be negative ; volume of the cube ; Driver code
class Solution { static float cube ( float h , float r ) { if ( h < 0 && r < 0 ) return - 1 ; float a = ( float ) Math . pow ( h , 3 ) ; return a ; } public static void main ( String args [ ] ) { float h = 5 , r = 4 ; System . out . println ( cube ( h , r ) ) ; } }