Question: Now we combine both methods into a test program. Note that both methods are contained in the same class. Also note the comment that describes

Now we combine both methods into a test program. Note that both methods are contained in the same class. Also note the comment that
describes the behavior of the cubeVolume method. (Programming Tip 5.2.1 describes the format of the comment.)
zyDE 5.2.1: Cubes.java.
Cubes.java
/**
This program computes the volumes of two cubes.
*/
public class Cubes
{
public static void main(String[] args)
{
double result1= cubeVolume(2);
double result2= cubeVolume(10);
System.out.println("A cube with side length 2 has volume "+ result1);
System.out.println("A cube with side length 10 has volume "+ result2);
}
/**
Computes the volume of a cube.
@param sideLength the side length of the cube
@return the volume
*/
public static double cubeVolume(double sideLength)
{
double volume = sideLength * sideLength * sideLength;
return volume;
}
}
Now we combine both methods into a test program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!