// Application to calculate sphere volumes - shows syntax of methods import java.io.*; public class Volume { static private double radius,volume; public static void main (String[] args) { /* uses method from Console class to read formatted input - prints the argument as a prompt, then reads a double terminated by a newline */ radius = Console.readDouble("Type in the radius of the sphere: "); volume = sphereVolume(radius); System.out.println("Volume is " + volume + "\n"); } // this method is called locally with one argument of type double // and returns a double static private double sphereVolume(double rad) { double vol; vol = (4.0/3.0) * Math.PI * Math.pow(rad,3); return vol; } }