Volume And Surface Area Of Sphere In Java
Chapter:
Math Class
Last Updated:
04-05-2016 18:51:48 UTC
Program:
/* ............... START ............... */
import java.util.Scanner;
public class JavaVolumeAndSurfaceAreaOfSphere {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double radius = 0;
double volume = 0;
double area = 0;
System.out.print("Radius of Sphere: ");
radius = input.nextDouble();
volume = (4 * Math.PI * Math.pow(radius, 3)) / 3;
area = 4 * Math.PI * Math.pow(radius, 2);
System.out.println("Volume : " + volume);
System.out.println("Surface Area : " + area);
}
}
/* ............... END ............... */
Output
Radius of Sphere: 15
Volume : 14137.16694115407
Surface Area : 2827.4333882308138
Tags
Volume And Surface Area Of Sphere, Java, Math