Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GeometryCalculator {
- public static float areaCircle( float radius ) {
- if( radius < 0 )
- System.out.println("Can not have negative numbers");
- return (float) (Math.PI * ( radius * radius ));
- }
- public static float areaRectangle(float length, float width){
- if( length < 0 || width < 0 )
- System.out.println("Can not have negative numbers");
- return (float) ( length * width );
- }
- public static float areaTriangle(float base, float height){
- if( base < 0 || height < 0)
- System.out.println("Can not have negative numbers");
- return (float) ( base * height * 0.5 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement