Largest sphere that can be inscribed in a right circular cylinder inscribed in a frustum | Java Program to find the biggest sphere that can be inscribed within a right circular cylinder which in turn is inscribed within a frustum ; Function to find the biggest sphere ; the radii and height cannot be negative ; radius of the sphere ; volume of the sphere ; Driver code
import java . lang . Math ; class gfg { static float sph ( float r , float R , float h ) { if ( r < 0 && R < 0 && h < 0 ) return - 1 ; float x = r ; float V = ( float ) ( 4 * 3.14f * Math . pow ( r , 3 ) ) / 3 ; return V ; } public static void main ( String [ ] args ) { float r = 5 , R = 8 , h = 11 ; System . out . println ( sph ( r , R , h ) ) ; } }