Largest right circular cylinder that can be inscribed within a cone | Java Program to find the biggest right circular cylinder that can be fit within a right circular cone ; Function to find the biggest right circular cylinder ; radius and height cannot be negative ; radius of right circular cylinder ; height of right circular cylinder ; volume of right circular cylinder ; Driver code
import java . io . * ; class GFG { static double cyl ( double r , double h ) { if ( r < 0 && h < 0 ) return - 1 ; double R = ( 2 * r ) / 3 ; double H = ( 2 * h ) / 3 ; double V = 3.14 * Math . pow ( R , 2 ) * H ; return V ; } public static void main ( String [ ] args ) { double r = 4 , h = 8 ; System . out . println ( cyl ( r , h ) ) ; } }