print
Advertisment
Advertisment

Volume of Cone

Example 2

import java.util.Scanner;
class Raj{

 public static void  main(String[] args) {
 
   float r;
   float h;
   float volume;

   Scanner sc = new Scanner(System.in);

   System.out.print("Enter radius of the cone :");
   r = sc.nextFloat();

   System.out.print("Enter height of the cone :");
   h = sc.nextFloat();

   volume = (float)((3.14 * r * r * h)/3);

   System.out.println("Volume of cone is: "+ volume);

    }
  }

Output :

 
   
  Enter radius of the cone :4
  Enter height of the cone :8
  Volume of cone is: 133.97333
   
Advertisment
Advertisment
arrow_upward