Java

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')

description

java file

Transcript of Java

Page 1: Java

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++;

Page 2: Java

}

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

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

}

}

Output

Page 3: Java

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