Declare method sphereVolume to calculate and return the volume of the sphere. Use the following statement to calculate the volume:
```
double volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3)
```
Write a Java application that prompts the user for the double radius of a sphere, calls sphereVolume
to calculate the volume and displays the result.
The following solution calculates the volume of a sphere, using the radius entered by the user:
```
// Sphere.java
// Calculate the volume of a sphere.
import java.util.Scanner;
public class Sphere {
// obtain radius from user and display volume of sphere
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter radius of sphere: ");
double radius = input.nextDouble();
System.out.printf("Volume is %f%n", sphereVolume(radius));
}
// calculate and return sphere volume
public static double sphereVolume(double radius) {
double volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);
return volume;
}
}
```
Enter radius of sphere: 4
Volume is 268.082573