5th sem OOPJ Create a class which asks the user to enter a sentence, and it should display count of each vowel type in the sentence. The program should continue till user enters a word “quit”. Display the total count of each vowel for all sentences.
import java.util.*;
/**
*
* @author Yash
*/
public class pra8 {
public static void main(String arg[]){
String s1 = new String();
while(!s1.equals("quit")){
char ch;
int vol=0,cont=0;
System.out.println("Enter the String..");
Scanner sc = new Scanner(System.in);
s1 = sc.nextLine();
StringBuffer sb = new StringBuffer(s1);
for(int i=0;i<sb.length();i++){
ch = sb.charAt(i);
if( ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U'){
vol++;
}else{
cont++;
}
}
System.out.println("voweles : "+vol);
System.out.println("Consonants :" +cont);
}
}
}
Comments
Post a Comment