Compute the volume and surface area of a sphere


Discuss the below:

Q: Write static methods

- public static double sphereVolume(double r)
- public static double sphereSurface(double r)
- public static double cylinderVolume(double r, double h)
- public static double cylinderSurface(double r, double h)
- public static double coneVolume(double r, double h)
- public static double coneSurface(double r, double h)

that compute the volume and surface area of a sphere with radius r, a cylinder with circular base with radius r and height h, and a cone with circular base with radius r and height h. Place them into a class Geometry. Then write a program that prompts the user for the values of r and h, calls the six methods, and prints the results.

Here is a sample program run:
Please enter the radius: 5
Please enter the height: 10
The volume of the sphere is: 523.5987755982989
The surface area of the sphere is: 314.1592653589793
The volume of the cylinder is: 785.3981633974483
The surface area of the cylinder is: 471.23889803846896
The volume of the cone is: 261.79938779914943
The surface area of the cone is: 254.160184615763

Your main class should be called GeometryCalculator.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Compute the volume and surface area of a sphere
Reference No:- TGS01934126

Now Priced at $25 (50% Discount)

Recommended (94%)

Rated (4.6/5)