-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteenNumberChecker.java
More file actions
36 lines (30 loc) · 907 Bytes
/
Copy pathteenNumberChecker.java
File metadata and controls
36 lines (30 loc) · 907 Bytes
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
import java.util.Scanner;
public class TeenNumberChecker{
public static boolean hasTeen(int a, int b, int c){
return isTeen(a) || isTeen(b) || isTeen(c);
}
public static boolean isTeen(int num){
return num >= 13 && num <= 19;
}
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.print("Enter three numbers: ");
int a=s.nextInt();
int b=s.nextInt();
int c=s.nextInt();
boolean hasTeen = hasTeen(a, b, c);
if(hasTeen){
System.out.println("true");
} else {
System.out.println("false");
}
System.out.print("Enter a number: ");
int num=s.nextInt();
boolean isTeen = isTeen(num);
if(isTeen){
System.out.println("true");
} else {
System.out.println("false");
}
}
}