import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
/**
* 判断除字符串是否符合第一种规则
*/
public static boolean isAllUpper(String str) {
// 只要除了首字母以外的字母出现小写,即不符合规则。应该转换
char temp;
for (int index = 0; index < str.length(); index++) {
temp = str.charAt(index);
if (temp <= 'z' && temp >= 'a') {
return false;
}
}
return true;
}
/**
* 判断除字符串是否符合第二种规则
*/
public static boolean isLowUpper(String str) {
// 只要除了首字母以外的字母出现小写,即不符合规则。应该转换
if (str.charAt(0) <= 'Z' && str.charAt(0) >= 'A') {
return false;
}
char temp;
for (int index = 1; index < str.length(); index++) {
temp = str.charAt(index);
if (temp <= 'z' && temp >= 'a') {
return false;
}
}
return true;
}
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(System.out);
String inputWord; // 输入的单词
String changeWord;// 转换之后的单词
while (in.hasNext()) {
inputWord = in.next();
changeWord = inputWord;
if (isAllUpper(inputWord)) {
changeWord = inputWord.toLowerCase();
}else if(isLowUpper(inputWord)){
changeWord = inputWord.substring(0, 1).toUpperCase() + inputWord.substring(1).toLowerCase();
}
out.println(changeWord);
}
out.flush();
}
}
04-11
179
05-07
388