-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter_Count.java
46 lines (46 loc) · 1.16 KB
/
Character_Count.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
//Read description for question//
import java.util.*;
public class Main
{
public static void main(String...args)
{
Scanner obj=new Scanner(System.in);
String s=obj.nextLine();
char[] ch=s.toCharArray();
int spa=0,spe=0,v=0,c=0;
for(int i=0;i<s.length();i++)
{
if(ch[i]>=65 && ch[i]<=90)
{
if(ch[i]=='A' || ch[i]=='E' || ch[i]=='I' || ch[i]=='O' || ch[i]=='U')
{
v++;
}
else
{
c++;
}
}
else if(ch[i]>=97 && ch[i]<=122)
{
if(ch[i]=='a' || ch[i]=='e' || ch[i]=='i' || ch[i]=='o' || ch[i]=='u')
{
v++;
}
else
{
c++;
}
}
else if(ch[i]==32)
{
spa++;
}
else
{
spe++;
}
}
System.out.println("Vowels: "+v+"\nConsonants: "+c+"\nSpecial Character: "+spe+"\nSpaces: "+spa);
}
}