Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa HTML ERIYANA ARIS
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


qiaqez
ERIYANA ARIS
1 Answer(s)      2 years and 8 months ago
Posted in : HTML


write a java complete program to calculate to number of each vowel characters in a string given by user.Each vowel character should be representing using lower case latter.

example ; ERIYANA ARIS


Advertisement
View Answers

January 21, 2012 at 5:33 PM


import java.io.*;

class  CountCharacters {
  public static void main(String[] args) throws Exception{
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  System.out.print("Please enter string ");
  System.out.println();
  String str=br.readLine();
  String st=str.replaceAll(" ", "");

  char[]third =st.toCharArray();
  for(int counter =0;counter<third.length;counter++){
  char ch= third[counter];
  int count=0;
  for ( int i=0; i<third.length; i++){
  if (ch==third[i])
  count++;
}
boolean flag=false;
for(int j=counter-1;j>=0;j--){
if(ch==third[j])
flag=true;
}
if(!flag){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
System.out.println("Character :"+ch+" occurs "+count+" times ");
}
  }
}
}
}


Related Tutorials/Questions & Answers:
ERIYANA ARIS
ERIYANA ARIS  write a java complete program to calculate to number of each vowel characters in a string given by user.Each vowel character should be representing using lower case latter. example ; ERIYANA ARIS   import
Advertisements
 

 

 

DMCA.com