-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03005.java
More file actions
33 lines (30 loc) · 1 KB
/
Copy pathJ03005.java
File metadata and controls
33 lines (30 loc) · 1 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
33
import java.util.*;
public class J03005 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
while (n-- >0) {
String tmp = sc.nextLine();
String s = tmp.trim();
StringBuilder sb = new StringBuilder("");
String[] a = s.split("\\s+");
boolean check = false;
for (String i : a) {
if (!check) {
check = true;
continue;
}
sb.append(Character.toUpperCase(i.charAt(0)));
for (int j = 1; j<i.length(); j ++) {
sb.append(Character.toLowerCase(i.charAt(j)));
}
sb.append(" ");
}
sb.deleteCharAt(sb.length()-1);
sb.append(", ");
sb.append(a[0].toUpperCase());
System.out.println(sb.toString());
}
}
}