
write a program to accept strig from user and find out vowel,blank and non blank characters.

Hi Friend,
Try the following code:
import java.util.*;
class StringQueries{
public static boolean isVowel(char s) {
String st="aeiouAEIOU";
int i;
for (i=0;i<10;i++) {
char ch=st.charAt(i);
if (ch==s)
return true;
}
return false;
}
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter string: ");
int count=0;
int countBlank=0;
int countNonBlank=0;
String st=input.nextLine();
String str=st.replace(" ","");
char ch[]=str.toCharArray();
for(int i=0;i<ch.length;i++){
boolean is=StringQueries.isVowel(ch[i]);
if(is){
System.out.println(ch[i]);
count++;
}
else{
countNonBlank++;
}
}
System.out.println("There is/are "+count+" vowels in the given string.");
for(int i=0;i<st.length();i++){
if(Character.isWhitespace(st.charAt(i))){
countBlank++;
}
}
System.out.println("There is/are "+countBlank+" blank charatcers in the given string.");
System.out.println("There is/are "+countNonBlank+" non blank charatcers in the given string.");
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.