Last active
August 1, 2019 15:20
-
-
Save 0ryant/a829b42a8a0c1c111097919967ef7b70 to your computer and use it in GitHub Desktop.
Java - Coding Challenge 7 - TeenNumberChecker
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 TeenNumberChecker { | |
public static boolean hasTeen(int a,int b,int c){ | |
if (a >=13 && a <=19 || | |
b >=13 && b <=19 || | |
c >=13 && c <=19 ) { | |
return true; | |
} | |
return false; | |
// Or, this is a little more elegant : | |
// return isTeen(a) || isTeen(b) || isTeen(c); | |
} | |
public static boolean isTeen(int a) { | |
if (a <13 || a >19){ | |
return false; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment