-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathCountVowel.java
35 lines (32 loc) · 1.03 KB
/
CountVowel.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
/* Count number of vowel, consonent and digit into a string */
import java.util.*;
public class CountVowel {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int v =0;
int c=0;
int num=0;
for(int i=0; i<s.length(); i++)
{
if(Character.isLetter(s.charAt(i)))
{
if(s.charAt(i)=='A'||s.charAt(i)=='a'||s.charAt(i)=='E'||s.charAt(i)=='e'||s.charAt(i)=='I'||s.charAt(i)=='i'||s.charAt(i)=='O'||s.charAt(i)=='o'||s.charAt(i)=='U'||s.charAt(i)=='u')
{
v++;
}
else
{
c++;
}
}
else if(Character.isDigit(s.charAt(i)))
{
num++;
}
}
System.out.println("Vowel : "+v);
System.out.println("Consonant : "+c);
System.out.println("Number : "+num);
}
}