Static Methods for Geometry
Not what you're looking for?
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
Purchase this Solution
Solution Summary
This solution implements some static methods for geometry.
Purchase this Solution
Free BrainMass Quizzes
C++ Operators
This quiz tests a student's knowledge about C++ operators.
C# variables and classes
This quiz contains questions about C# classes and variables.
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.
Word 2010: Tables
Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.
Java loops
This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.