-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-13.java
More file actions
26 lines (26 loc) · 810 Bytes
/
Copy pathQue-13.java
File metadata and controls
26 lines (26 loc) · 810 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
//Write a program to accept a line and check how many consonants and vowels are there in line.
//By: Parth Panjwani
import java.util.*;
class Que13
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a line: ");
String line = sc.nextLine();
int vowels = 0, consonants = 0;
for(int i = 0; i < line.length(); i++)
{
if(line.charAt(i) == 'a' || line.charAt(i) == 'e' || line.charAt(i) == 'i' || line.charAt(i) == 'o' || line.charAt(i) == 'u')
{
vowels++;
}
else
{
consonants++;
}
}
System.out.println("Vowels: "+vowels);
System.out.println("Consonants: "+consonants);
}
}