-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounting.java
51 lines (45 loc) · 893 Bytes
/
Counting.java
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
import java.util.*;
public class Counting {
public static void main(String[] args) {
int a=0;
int e= 0;
int i=0;
int o=0;
int u=0;
int sum=0;
String words;
Scanner input = new Scanner(System.in);
System.out.print("Enter string: ");
words = input.nextLine();
words = words.toLowerCase();
for(int times = 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);
}
}