Calculate volume and surface area of a cone | Java program to calculate Volume and Surface area of cone ; Function to calculate Volume of cone ; Function to calculate Surface area of cone ; Driver Code ; Printing value of volume and surface area
class GFG { static float pi = 3.14159f ; public static float volume ( float r , float h ) { return ( float ) 1 / 3 * pi * h * r * r ; } public static float surface_area ( float r , float s ) { return pi * r * s + pi * r * r ; } public static void main ( String args [ ] ) { float radius = 5 ; float slant_height = 13 ; float height = 12 ; float vol , sur_area ; System . out . print ( " Volume ▁ Of ▁ Cone ▁ : ▁ " ) ; System . out . println ( volume ( radius , height ) ) ; System . out . print ( " Surface ▁ Area ▁ Of ▁ Cone ▁ : ▁ " ) ; System . out . println ( surface_area ( radius , slant_height ) ) ; } }