Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.lang.Math;
  2.  
  3. public class Geometry {
  4.    
  5.     public static double sphereVolume(double r){
  6.        
  7.         double sphereVolume = (4/3) * Math.PI * r * r;
  8.         return sphereVolume;
  9.        
  10.     }
  11.    
  12.     public static double sphereSurface(double r){
  13.        
  14.         double sphereSurface = 4 * Math.PI * r * r;
  15.         return sphereSurface;
  16.     }
  17.    
  18.     public static double cylinderVolume(double r, double h){
  19.        
  20.         double cylinderVolume = Math.PI * r * r * h;
  21.         return cylinderVolume;
  22.     }
  23.    
  24.     public static double cylinderSurface(double r, double h){
  25.        
  26.         double cylinderSurface = (2 * Math.PI * r * h) + (2 * Math.PI * r * r);
  27.         return cylinderSurface;
  28.     }
  29.    
  30.     public static double coneVolume(double r, double h){
  31.        
  32.         double coneVolume = 1/3 * Math.PI * r * r * h;
  33.         return coneVolume;
  34.     }
  35.    
  36.     public static double coneSurface(double r, double h){
  37.        
  38.         double coneSurface = (Math.PI * r) * ( r + Math.sqrt((h* h) + (r * r)));
  39.         return coneSurface;
  40.        
  41.     }
  42.    
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement