
package practice.test.coding;
import java.util.Scanner;
public class CaseConversion {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String str = kb.nextLine();
String str2 = "";
int strlength = str.length();
if(strlength <= 100) {
for(int i=0; i<strlength; i++) {
char ch = str.charAt(i);
if((int)ch >= 65 && (int)ch <= 90) str2 += Character.toLowerCase(ch);
if((int)ch >= 97 && (int)ch <= 122) str2 += Character.toUpperCase(ch);
}
System.out.println(str2);
} else {
System.out.println("100 글자 이하의 영어 알파벳만 입력해 주세요.");
}
}
}

대문자의 경우 소문자로, 소문자의 경우 대문자로 변환되어 출력된다.
char형 문자를 소문자로 바꾸는 메소드
char형 문자를 대문자로 바꾸는 메소드
ASCII 10진수 숫자 (0~9) 48~57 알파벳 대문자 (A~Z) 65~90 알파벳 소문자 (a~z) 97~122
따라서
알파벳 대문자의 경우 65 <= 대문자 <= 90
알파벳 소문자의 경우 97 <= 소문자 <= 122
이러한 범위로 구분하면 된다. 😎