-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringzz.java
More file actions
32 lines (27 loc) · 783 Bytes
/
stringzz.java
File metadata and controls
32 lines (27 loc) · 783 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
29
30
31
32
import java.util.*;
public class stringzz
{
public static void main(System[]args) {
System.out.println("");
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
int k = 0;
String sub = "";
for(int i=0; i<str.length(); i++) {
if(str.charAt(i)>='A' && str.charAt(i)<='z') {
if(k%2==0){
sub = sub + Character.toUpperCase(str.charAt(i));
k++;
}
else {
sub = sub + Character.toLowerCase(str.charAt(i));
k++;
}
}
else {
sub = sub + str.charAt(i);
}
}
System.out.println(sub);
}
}