-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTeenNumberChecker.java
More file actions
52 lines (36 loc) · 1.78 KB
/
TeenNumberChecker.java
File metadata and controls
52 lines (36 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*********************************************************************************************************************
Teen Number Checker
===================
We'll say that a number is "teen" if it is in the range 13 -19 (inclusive).
Write a method named hasTeen with 3 parameters of type int.
The method should return boolean and it needs to return true if one of the parameters is in range 13(inclusive) - 19 (inclusive). Otherwise return false.
EXAMPLES OF INPUT/OUTPUT:
hasTeen(9, 99, 19); should return true since 19 is in range 13 - 19
hasTeen(23, 15, 42); should return true since 15 is in range 13 - 19
hasTeen(22, 23, 34); should return false since numbers 22, 23, 34 are not in range 13-19
Write another method named isTeen with 1 parameter of type int.
The method should return boolean and it needs to return true if the parameter is in range 13(inclusive) - 19 (inclusive). Otherwise return false.
EXAMPLES OF INPUT/OUTPUT:
isTeen(9); should return false since 9 is in not range 13 - 19
isTeen(13); should return true since 13 is in range 13 - 19
NOTE: All methods need to be defined as public static like we have been doing so far in the course.
NOTE: Do not add a main method to solution code.
**********************************************************************************************************************/
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;
}
else{
return false;
}
}
public static boolean isTeen(int n){
if (n>=13 && n<=19 ){
return true;
}
else{
return false;
}
}
}