-
Notifications
You must be signed in to change notification settings - Fork 0
/
J03005
36 lines (33 loc) · 1.08 KB
/
J03005
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
package test;
import java.util.*;
public class J03005 {
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() + " ";
Vector<String> v = new Vector<String>();
String x = "";
for(int i = 0; i < s.length(); i++){
if(s.charAt(i) == ' '){
if(x != ""){
v.add(x);
x = "";
}
}
else {
x += s.charAt(i);
}
}
for(int i = 1; i < v.size(); i++){
String k = v.get(i);
if(i == v.size()-1) System.out.print(k.substring(0,1).toUpperCase() + k.substring(1));
else System.out.print(k.substring(0,1).toUpperCase() + k.substring(1)+ " ");
}
System.out.print(", " + v.get(0).toUpperCase());
System.out.println();
}
}
}