How to calculate the volume of cone in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        int radius = 12;  
        int height = 25;

        double cone_volume = Math.PI * (radius * radius) * height / 3;
 
        System.out.println("Cone volume = " + cone_volume);
    }
}
 
 
 
 
 
/*
run:
    
Cone volume = 3769.9111843077517
   
*/

 



answered Jul 14, 2021 by avibootz
edited May 10, 2023 by avibootz

Related questions

1 answer 128 views
1 answer 132 views
1 answer 125 views
1 answer 336 views
1 answer 318 views
1 answer 152 views
152 views asked Jul 14, 2021 by avibootz
1 answer 126 views
...