-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawsmdudeCode1.java
More file actions
73 lines (61 loc) · 2.36 KB
/
awsmdudeCode1.java
File metadata and controls
73 lines (61 loc) · 2.36 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package FML;
import java.util.Scanner;
public class awsmdudeCode1 {
public static char[] vowels = {'a', 'e', 'o', 'u', 'i'};
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int times = Integer.parseInt(scanner.nextLine());
if (1 <= times && times <= 20) {
String[] inputs = new String[times];
for (int i = 0; i < inputs.length; i++) {
inputs[i] = scanner.nextLine();
}
System.out.println(ratio(inputs)+" "+vowelCounter(ratio(inputs))+"/"+letterCounter(ratio(inputs)));
}
}
public static boolean isVowel(char c) { // проверява дали е гласната
c = Character.toLowerCase(c);
for (char d : vowels) {
if (c == d)
return true;
}
return false;
}
public static int vowelCounter(String a) { //калкулира гласните
char[] box = a.toCharArray();
int vowelCounter = 0;
for (int i = 0; i < box.length; i++) {
if (isVowel(box[i])) {
vowelCounter++;
}
}
return vowelCounter;
}
public static int letterCounter(String b) { //калкулира букбите
int letterCounter = 0;
for (int i = 0; i < b.length(); i++) {
letterCounter++;
}
return letterCounter;
}
public static String ratio(String [] a){ //главната проверка
String output = a[0];
for (int i = 1; i < a.length; i++) {
if (vowelCounter(a[i]) > vowelCounter(output) && letterCounter(a[i]) < letterCounter(output)){
output = a[i];
} if (vowelCounter(a[i]) == vowelCounter(output) && letterCounter(a[i]) == letterCounter(output) || vowelCounter(a[i]) == 0 && vowelCounter(output) ==0 || letterCounter(a[i]) == letterCounter(output)){
output = theLongest(a);
}
}
return output;
}
public static String theLongest(String[] a){ //най-дългата дума
String output = a[0];
for (int i = 0; i < a.length; i++) {
if (a[i].length() > output.length()){
output = a[i];
}
}
return output;
}
}