-
Notifications
You must be signed in to change notification settings - Fork 0
/
131A - cAPS lOCK.java
51 lines (49 loc) · 1.4 KB
/
131A - cAPS lOCK.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Scanner;
public class capslock {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String str = "";
boolean flag = false;
boolean flag2 = false;
if(s.charAt(0)>='A' && s.charAt(0)<='Z'){
for(int i = 1;i<s.length();i++){
if(s.charAt(i)>='A' && s.charAt(i)<='Z'){
continue;
}
else{
System.out.println(s);
flag = true;
return;
}
}
flag2 = true;
}
if(s.charAt(0)>='a' && s.charAt(0)<='z'){
for(int i = 1;i<s.length();i++){
if(s.charAt(i)>='A' && s.charAt(i)<='Z'){
continue;
}
else{
System.out.println(s);
flag = true;
return;
}
}
}
if(flag2 == true){
s = s.toLowerCase();
System.out.println(s);
return;
}
if(flag == false){
str += s.charAt(0);
str = str.toUpperCase();
s = s.toLowerCase();
for(int i = 1;i<s.length();i++){
str += s.charAt(i);
}
System.out.println(str);
}
}
}