-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2.java
More file actions
28 lines (22 loc) · 665 Bytes
/
Copy pathP2.java
File metadata and controls
28 lines (22 loc) · 665 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
package ch1;
import java.util.Locale;
import java.util.Scanner;
public class P2 {
public static String solution(String str){
String result ="";
for(int i =0; i<str.length(); i++){
if(Character.isLowerCase(str.charAt(i))) {
result += Character.toUpperCase(str.charAt(i));
}else{
result += Character.toLowerCase(str.charAt(i));
}
}
return result;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
String answer = solution(str);
System.out.println(answer);
}
}