-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletter.java
More file actions
37 lines (34 loc) · 876 Bytes
/
letter.java
File metadata and controls
37 lines (34 loc) · 876 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
import java.io.*;
class letter
{
public static void main(String[] args)
{
String line = "This website is aw3som3.";
int vowels = 0, consonants = 0, digits = 0, spaces = 0;
line = line.toLowerCase();
for (int i = 0; i < line.length(); ++i)
{
char ch = line.charAt(i);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
{
++vowels;
}
else if ((ch >= 'a' && ch <= 'z'))
{
++consonants;
}
else if (ch >= '0' && ch <= '9')
{
++digits;
}
else if(ch==' ')
{
++spaces;
}
}
System.out.println("Vowels: " + vowels);
System.out.println("Consonants: " + consonants);
System.out.println("Digits:"+digits);
System.out.println("White spaces: " + spaces);
}
}