-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCF131ACapsLock.java
More file actions
32 lines (27 loc) · 1.07 KB
/
CF131ACapsLock.java
File metadata and controls
32 lines (27 loc) · 1.07 KB
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See <a href="http://codeforces.com/problemset/problem/131/A">cAPS lOCK</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class CF131ACapsLock {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
String s = in.readLine();
if (s.length() == 1) {
out.print(s.equals(s.toUpperCase()) ? s.toLowerCase() : s.toUpperCase());
} else if (s.substring(1).equals(s.substring(1).toUpperCase())) {
String firstLetter = s.substring(0, 1);
String complement = s.substring(1).toLowerCase();
firstLetter = firstLetter.equals(firstLetter.toUpperCase()) ? firstLetter.toLowerCase() : firstLetter.toUpperCase();
out.print(firstLetter + complement);
} else {
out.print(s);
}
out.close();
}
}