Explore BrainMass
Share

Static Methods for Geometry

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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.

You need to supply the following class in your solution: Geometry

© BrainMass Inc. brainmass.com October 25, 2018, 9:27 am ad1c9bdddf
https://brainmass.com/computer-science/java/static-methods-for-geometry-574613

Solution Summary

This solution implements some static methods for geometry.

$2.19
See Also This Related BrainMass Solution

Coastal Protection Strategies: Dynamic and Static Armoring

In dynamic armouring smaller particles are used and they are allowed to adjust by erosion and deposition to the prevailing wave climate, while still protecting the finer particles behind them from being washed away. In static armouring very large stones are placed to lock the shore in place - no movement is anticipated even in the worst storm. What are the advantages and disadvantages in both human terms (use, appearance, cost) and natural terms of the two strategies for coastal protection?

View Full Posting Details