Question: Hello, i need hlep with this question and the answer has to be in Java! Thanks In this assignment you are to implement and test
Hello, i need hlep with this question and the answer has to be in Java! Thanks
In this assignment you are to implement and test each of the following methods
//returns the volume of a cube whose side length is sideLength
public static double boxVolume(double sideLength)
//returns the surface area of a cube whose side length is sideLength
public static double boxSurfaceArea(double sideLength)
//returns the volume of a sphere whose radius is radius
public static double ballVolume(radius)
//returns the surface area of a sphere whose radius is radius
public static double ballSurfaceArea(double radius)
//returns the volume of the largest sphere that will fit inside a box whose side length is //sideLength
public static double ballInBox(double sideLength)
//returns the volume of the largest cube that will fit inside a sphere whose radius is radius
public static double boxInBAll(double radius)
You must use the following main method in your program:
public static void main (String[] args) {
// Initialize local variable for each parameter argument
//sideLength for cube, and sphere//
double sideLength = 2.0;
// radius for ball
double radius = 6.0;
// Define, invoke boxVolume method
System.out.println("The volume of a box with a side length of "
+ sideLength + " is " + boxVolume(sideLength));
// Define , invoke boxSurfaceArea method
System.out.println("The surface area of a box with a side length of "
+ sideLength + " is " + boxSurfaceArea(sideLength));
// Define, invoke ballVolume method
System.out.println("The volume of a ball with a radius of "
+ radius + " is " + ballVolume(radius));
// Define, invoke ballSurfaceArea method
System.out.println("The surface area of a ball with a radius of "
+ radius + " is " + ballSurfaceArea(radius));
// Define, invoke ballInBox method
System.out.println("The volume of the largest ball that" +
" can be placed inside a box with a side length of "
+ sideLength + " is " + ballInBox(sideLength));
// Define, invoke boxInBall method
System.out.println("The volume of the largest box that"
+ " can be placed inside a ball with a radius of "
+ radius + " is " + boxInBall(radius));
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
