- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounting.java
More file actions
Latest commit
51 lines (45 loc) · 893 Bytes
/
Copy pathCounting.java
File metadata and controls
51 lines (45 loc) · 893 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
importjava.util.*;
publicclassCounting {
publicstaticvoidmain(String[] args) {
inta=0;
inte= 0;
inti=0;
into=0;
intu=0;
intsum=0;
Stringwords;
Scannerinput = newScanner(System.in);
System.out.print("Enter string: ");
words = input.nextLine();
words = words.toLowerCase();
for(inttimes = 0; times < words.length(); times++)
{
if(words.charAt(times) == 'a'){
sum++;
a++;
}
if(words.charAt(times) == 'e'){
sum++;
e++;
}
if(words.charAt(times) == 'i'){
sum++;
i++;
}
if(words.charAt(times) == 'o'){
sum++;
o++;
}
if(words.charAt(times) == 'u'){
sum++;
u++;
}
}
System.out.println("A: "+ a);
System.out.println("E: "+ e);
System.out.println("I: "+ i);
System.out.println("O: "+ o);
System.out.println("U: "+ u);
System.out.println("Total Sum: "+ sum);
}
}