
Example: Java program to
calculate surface area and volume of sphere


//Program name Main105.java
//Java program to calculate surface area and
volume of sphere
import java.util.*;
public class Main105
{
public static void main(String[] args)
{
System.out.print("Enter
radius of a sphere: ");
Scanner scan = new
Scanner(System.in);
double rad = scan.nextDouble();
double sarea = 4*Math.PI*rad*rad;
double volume =
4*Math.PI*rad*rad*rad/3;
System.out.println("Surface
area = " + sarea);
System.out.println("Volume = " +
volume);
}
}

Output

Enter radius of a sphere: 15
Surface area = 2827.4333882308138
Volume = 14137.16694115407
