Created
August 6, 2019 11:08
-
-
Save 0ryant/64e95caa93bb2c0cacf690f86edf3486 to your computer and use it in GitHub Desktop.
Java - Coding Challenge 8 - AreaCalculator (Method Overloading)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AreaCalculator { | |
public static double area (double radius) { | |
if (radius<0) { | |
return -1.0d; | |
} | |
double areaOfCircle = ((Math.PI * (radius*radius))); | |
return areaOfCircle; | |
} | |
public static double area (double x, double y) { | |
if ((x<0)||(y<0)){ | |
return -1.0d; | |
} | |
double areaOfSquare = x*y; | |
return areaOfSquare; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment