This example show you how to check and calculate how many vowel are in the string entered by user. With the help of for loop, we calculate how many vowels a user entered in the string. Here is the source code :
import java.lang.String;
import java.io.*;
import java.util.*;
public class vowels{
public static void main(String args[])throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter New String to Check :");
String text = bf.readLine();
int cnt = 0;
for (int a = 0; a < text.length(); a++) {
char b = text.charAt(a);
if (b=='a' || b=='e' || b=='i' || b=='o' || b=='u') {
cnt++;
}
}
System.out.println("Total Vowels are" + " : " + cnt);
}
}
Saturday, June 21, 2008
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment