-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBar.java
More file actions
36 lines (33 loc) · 716 Bytes
/
Bar.java
File metadata and controls
36 lines (33 loc) · 716 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.io.*;
import java.util.*;
public class Bar{
static boolean fun(String s){
List<String> alcohol = Arrays.asList("ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE");
if(alcohol.contains(s)){
return true;
}else{
try{
int num = Integer.parseInt(s);
if(num>=18)
return false;
else
return true;
}catch(NumberFormatException e){
return false;
}
}
}
public static void main(String args[]){
int n,i,c=0;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
sc.nextLine();
for(i=0;i<n;i++){
String s = sc.nextLine();
boolean res = fun(s);
if(res)
c++;
}
System.out.print(c);
}
}