Volume of Sphere
previous NextExample 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