You are on page 1of 3

QUES-1 Write a program to read and count no.

of consonant and vowel in both


cases
import java.io.*;
class vowel
{
public static void main(String args[]) throws IOException
{
String str;
int vowels = 0, consonent=0;
char ch;

BufferedReader br = new BufferedReader(new


InputStreamReader(System.in));

System.out.print("Enter a String : ");


str = br.readLine();

for(int i = 0; i < str.length(); i ++)


{
ch = str.charAt(i);

if(ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' ||


ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
vowels ++;
else
consonent++;

System.out.println("Vowels : " + vowels);


System.out.println("Consonent : " + consonent);

}
}
Output

QUES-2 Write a program to read a file and count no. of spaces, no. of word, no. of
line

You might also like