Home Java Java-tips Data Strings Q-pr-string-using-loops Programming - countVowels() method

Ask Questions?

View Latest Questions

Advertisement


 
 

Programming - countVowels() method
Posted on: July 26, 2006 at 12:00 AM
Write a method which has one parameter, a string, and it returns the int number of vowels (a e i o u) in the string.

Java: Programming - countVowels() method

Problem

Write a method which has one parameter, a string, and it returns the int number of vowels (a e i o u) in the string.

Details

  • Vowels. It should regard a, e, i, o, and u as the vowels.
  • Case. It should handle both upper and lower case vowels.
  • No I/O. As usual, this method should do no I/O.
  • Method header. The method should be defined using this header.
    public static int countVowels(String text)
  • Example.
    x = countVowels("Chocolate Ice Cream");
    This would assign 8 to x.
Advertisement


DMCA.com