Difference between revisions of "Vowel Counter"
From CompSciWiki
m |
m |
||
Line 40: | Line 40: | ||
{ | { | ||
//check if it's a vowel | //check if it's a vowel | ||
− | if( input.charAt( i ) == 'a' | + | if( input.charAt( i ) == 'a' {{!}}{{!}} input.charAt( i ) == 'e' |
− | + | {{!}}{{!}} input.charAt( i ) == 'i' {{!}}{{!}} input.charAt( i ) == 'o' | |
− | + | {{!}}{{!}} input.charAt( i ) == 'u' ) | |
{ | { | ||
vowelCount++; //increment vowel count | vowelCount++; //increment vowel count |
Revision as of 23:25, 8 April 2010
Back to the Program-A-Day homepage
ProblemYour task is to write a program that takes a string of input from the user, and then count the number of vowels that are contained within this string. As output, provide the user with the final count of vowels, as well as the percentage of all characters in the string that these vowels represent. Repeat this until the user either cancels the input, or enters an empty string. For the purposes of this question, you may treat 'y' as though it is always a consonant (ie, just treat 'a', 'e', 'i', 'o', and 'u' as vowels). |
String Methods and Debugging
| |
---|---|---|
SolutionI still have to do the solution write-up... | ||
Code |