Advertisement
Guest User

geometrycalculator

a guest
Dec 17th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. public class GeometryCalculator {
  2.  
  3. public static float areaCircle( float radius ) {
  4.  
  5. if( radius < 0 )
  6.  
  7. System.out.println("Can not have negative numbers");
  8.  
  9. return (float) (Math.PI * ( radius * radius ));
  10.  
  11. }
  12.  
  13. public static float areaRectangle(float length, float width){
  14.  
  15. if( length < 0 || width < 0 )
  16.  
  17. System.out.println("Can not have negative numbers");
  18.  
  19. return (float) ( length * width );
  20.  
  21.  
  22.  
  23. }
  24.  
  25. public static float areaTriangle(float base, float height){
  26.  
  27. if( base < 0 || height < 0)
  28.  
  29. System.out.println("Can not have negative numbers");
  30.  
  31. return (float) ( base * height * 0.5 );
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement