-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck.java
More file actions
57 lines (35 loc) · 1002 Bytes
/
Copy pathCheck.java
File metadata and controls
57 lines (35 loc) · 1002 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.*;
import java.io.*;
//checks if the all the letters in the string are surrounded by +
class Check {
public static String SimpleSymbols(String str) {
char[] newStr = str.toCharArray();
int index = 0;
boolean flag = false;
if(Character.isLetter(newStr[0]) || Character.isLetter(newStr[str.length() - 1])) {
return "false";
}
++index;
while(index < str.length() - 1) {
if(Character.isLetter(newStr[index])) {
if(newStr[index - 1] == '+' && newStr[index + 1] == '+') {
flag = true;
} else {
flag = false;
}
}
index++;
}
if(flag == true) {
return "true";
} else {
return "false";
}
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(SimpleSymbols(s.nextLine()));
s.close();
}
}