I am trying to create a program that does the following:
"We'll say that a number is "teen" if it is in the range 13..19 inclusive. Given 3 int values, return true if 1 or more is teen.
My code:
public class hasTeen { public static void main() { System.out.println(" hasTeen(13, 20, 10) =" + hasTeen(13, 20, 10)); System.out.println(" hasTeen(20, 19, 10) =" + hasTeen(20, 19, 10)); System.out.println(" hasTeen(20, 10, 13)=" + hasTeen(20, 10, 13)); System.out.println("\n---end hasTeen---\n"); } public static boolean hasTeen(int a, int b, int c) { if ( a >= 13 && a<= 19 || b >= 11 && b<= 19 || c >= 13 || c<= 19) { return false; } else { return true; } } }
And when I run it they all come up false. Here's the original problem:
hasTeen(13, 20, 10) = true
hasTeen(20, 19, 10) = true
hasTeen(20, 10, 13) = true
I get false for all of these. What's wrong with my code?