Repository navigation
Expand file tree
/
Copy pathSimpleProgram
More file actions
61 lines (56 loc) · 1.7 KB
/
Copy pathSimpleProgram
File metadata and controls
61 lines (56 loc) · 1.7 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
/*
* Input format:
* The first line contains tc, the number of test cases.
* The second line contains the name of websites, as a string.
*
* Output format:
* You have to print the ratio of characters you would have typed in Jhool's browser, to your normal browser.
*
* Constraints:
* 1 <= tc <= 100
* 1 <= Length of the website <= 200
*
* NOTE: You do NOT need to print the output in its lowest format. You should print in its original fraction format.
* The names of all the websites will be in small case only.
*
* Every string will start from www. and end with .com, so well!
* Sample Input
*
* 2
* www.google.com
* www.github.com
*
* Sample Output
*
* 7/14
* 11/19
*/
// uncomment this if you want to read input.
import java.io.BufferedReader;
import java.io.InputStreamReader;
class TestClass {
public static void main(String args[] ) throws Exception {
/*
* Read input from stdin and provide input before running
*/
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int N = Integer.parseInt(line);
TestClass t = new TestClass();
for (int i = 0; i < N; i++) {
line = br.readLine();
t.calculateRatio(line);
}
//System.out.println("Hello World!");
}
private void calculateRatio (String line) {
int fullLength = line.length();
int reducedLength = fullLength - 3;
for (int i = 0; i<fullLength;i++){
if (line.charAt(i) == 'a' ||line.charAt(i) == 'e' ||line.charAt(i) == 'i' ||line.charAt(i) == 'o' || line.charAt(i) == 'u' ) {
reducedLength--;
}
}
System.out.println(reducedLength+"/"+fullLength);
}
}