Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chapter8;
- public class StaticFunctions {
- public static double cylinderVolume(double r, double h){
- double cylinderVolume;
- double circleArea;
- circleArea = Math.PI * Math.pow(r, 2);
- cylinderVolume = circleArea * h;
- return cylinderVolume;
- }
- public static double cylinderSurface(double r, double h){
- double cylinderSurface;
- cylinderSurface = (2 * Math.PI * r * h) + (2 * Math.PI * Math.pow(r, 2));
- return cylinderSurface;
- }
- public static double sphereVolume(double r){
- double sphereVolume;
- sphereVolume = (4/3) * Math.PI * Math.pow(r, 3);
- return sphereVolume;
- }
- public static double sphereSurface(double r){
- double sphereSurface;
- sphereSurface = 4 * Math.PI * Math.pow(r, 2);
- return sphereSurface;
- }
- public static double cubeVolume(double h){
- double cubeVolume;
- cubeVolume = Math.pow(h, 3);
- return cubeVolume;
- }
- public static double cubeSurface(double h){
- double cubeSurface;
- cubeSurface = 6 * (Math.pow(h, 2));
- return cubeSurface;
- }
- public static double coneVolume(double r, double h){
- double coneVolume;
- coneVolume = (1/3) * Math.PI * Math.pow(r,2) * h;
- return coneVolume;
- }
- public static double coneSurface(double r, double h){
- double coneSurface;
- double pyThag;
- pyThag = Math.pow(r, 2) + Math.pow(h, 2);
- coneSurface = (Math.PI * r) * (r + Math.pow(pyThag, .5));
- return coneSurface;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement