print
Advertisment
Advertisment

Volume of Sphere

Example 2

import java.util.Scanner;
class volumeofsphere{

 public static void  main(String[] args) {
 
  float radius;
  float volume;
  Scanner sc = new Scanner (System.in);
  System.out.print("Enter radius of the sphere : ");
  radius = sc.nextFloat();
  volume = (float)((4*3.14*radius*radius*radius)/3);
  System.out.println("volume of sphere is : "+ volume);

     }
   }

Output :

 
   
  Enter radius of the sphere : 5
  volume of sphere is : 523.3333

   
Advertisment
Advertisment
arrow_upward