-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ03005_ChuanHoaXauHoTen2.java
35 lines (32 loc) · 1.08 KB
/
J03005_ChuanHoaXauHoTen2.java
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
import java.util.*;
import java.io.*;
public class J03005_ChuanHoaXauHoTen2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
while (t-- > 0) {
String s = sc.nextLine();
s = s.toLowerCase();
StringTokenizer ss = new StringTokenizer(s);
Vector<String> v = new Vector<>();
Vector<String> v1 = new Vector<>();
while (ss.hasMoreTokens()) {
v.add(ss.nextToken());
}
String res = "";
for (int i = 1; i < v.size(); i++) {
String mp = v.elementAt(i);
char x = (char) (v.elementAt(i).charAt(0) - 32);
mp = x + mp.substring(1);
if (i < v.size() - 1) {
res += mp + " ";
} else {
res += mp + ", ";
}
}
res += v.elementAt(0).toUpperCase();
System.out.println(res);
}
}
}