-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathJ03029 - CHUẨN HÓA CÂU.java
More file actions
37 lines (31 loc) · 954 Bytes
/
J03029 - CHUẨN HÓA CÂU.java
File metadata and controls
37 lines (31 loc) · 954 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
33
34
35
36
37
import java.util.Scanner;
public class chuanhoacau {
String cleanParagraph(String source) {
source = source.trim();
source = source.replaceAll("\\s+", " ");
source = source.replaceAll("\\s+([.!?])", "$1");
source = source.toLowerCase();
source = source.substring(0, 1).toUpperCase() + source.substring(1);
if (Character.isAlphabetic(source.charAt(source.length() - 1))) {
source += '.';
}
return source;
}
void solve(int numTest) {
while (cin.hasNext()) {
String s = cin.nextLine();
System.out.println(cleanParagraph(s));
}
}
Scanner cin = new Scanner(System.in);
void Run() {
int t = 1;
// t = Integer.parseInt(cin.nextLine());
for (int i = 1; i <= t; i++) {
solve(i);
}
}
public static void main(String[] args) {
new chuanhoacau().Run();
}
}