Count words
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adam_Ibram
Posted On:   Monday, November 12, 2001 01:07 PM

I need to write a program which reads a line of text from the keyboard, terminated by a carriage return , into a suitable storage data type. The program should now print out the number of complete words in the line of text.
Now I need to modify the above program so that it also prints out the number of occurrences of each vowel (a,e,i,o,u) in the line of text.

Re: Count words

Posted By:   paresh_bhatia  
Posted On:   Monday, November 12, 2001 10:50 PM

String str = "this is a text";

char temp;

int word_count=0,avowel_count=0,evoel_cont=0;

for(int i=0;i
temp= str.chatAt(i);

if(temp=='a')

avowel_count++;

}else if(temp=='e')

evowel_count++;

}//similarly for other vowels

if(Character.isWhitespace(temp)) {

word_count++;

}
About | Sitemap | Contact