Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 6, 2019 11:08
Show Gist options
  • Save 0ryant/64e95caa93bb2c0cacf690f86edf3486 to your computer and use it in GitHub Desktop.
Save 0ryant/64e95caa93bb2c0cacf690f86edf3486 to your computer and use it in GitHub Desktop.
Java - Coding Challenge 8 - AreaCalculator (Method Overloading)
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