-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ03005.java
More file actions
38 lines (34 loc) · 1.22 KB
/
J03005.java
File metadata and controls
38 lines (34 loc) · 1.22 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
34
35
36
37
38
package CODE_PTIT;
import java.util.*;
import java.lang.*;
public class J03005 {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
int t = Integer.parseInt(inp.nextLine());
while (t-- > 0) {
String s = inp.nextLine();
s = s.toLowerCase();
String res[] = s.split("\\s+");
List<String> list = new ArrayList<>();
for(String x : res){
if(x.length() > 0){
list.add(x);
}
}
for (int i = 1; i < list.size(); i++) {
StringBuilder sb = new StringBuilder(list.get(i));
sb.setCharAt(0, (char)(list.get(i).charAt(0) - 32));
if(i == list.size() - 1)
System.out.print(sb + ", ");
else
System.out.print(sb + " ");
}
StringBuilder sb = new StringBuilder(list.get(0));
for(int i = 0; i < sb.length(); i++){
sb.setCharAt(i, (char)(list.get(0).charAt(i) - 32));
}
System.out.print(sb);
System.out.println();
}
}
}