-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecurityJava.java
36 lines (32 loc) · 972 Bytes
/
SecurityJava.java
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.*;
public class LearnJava {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String x = input.nextLine();
x = x.replaceAll("x", "");
List<Character> chars = new ArrayList<>();
for (char ch : x.toCharArray()) {
chars.add(ch);
}
//System.out.println(chars);
int Money = chars.indexOf('$');
int Thief = chars.indexOf('T');
//condition
if (Money < Thief) {
if ( chars.get(Money + 1).equals('G') ) {
System.out.println("quiet");
}else {
System.out.println("ALARM");
}
}
else if (Money > Thief ) {
if ( chars.get(Money - 1).equals('G') ) {
System.out.println("quiet");
}else {
System.out.println("ALARM");
}
}
else {
}
}
}