-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWord.java
More file actions
38 lines (38 loc) · 1.03 KB
/
Word.java
File metadata and controls
38 lines (38 loc) · 1.03 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
import java.util.*;
public class Word {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String word = sc.nextLine();
sc.close();
int nU = 0, nL = 0, len = word.length();
for(int i = 0; i < len; i++) {
if(word.charAt(i) <= 90) {
nU++;
} else {
nL++;
}
}
if(nU > nL) {
for(int i = 0; i < len; i++) {
char c = word.charAt(i);
if(c >= 97) {
print((char) (c - 'a' + 'A'));
} else {
print(c);
}
}
} else {
for(int i = 0; i < len; i++) {
char c = word.charAt(i);
if(c >= 97) {
print(c);
} else {
print((char) (c -'A' + 'a'));
}
}
}
}
private static void print(char c) {
System.out.print(String.valueOf(c));
}
}