Description
In English, there are some mechanical rules to turn a singular noun to plural. For this exercise, complete the method String...
In English, there are some mechanical rules to turn a singular noun to plural. For this exercise, complete the method String toPlural(String noun) that returns a plural version of the noun argument. You must implement the rules detailed below. Note that these rules do not cover all cases (e.g., the plural of man is not mans, but men), but for this exercise, you must implement only those described below.
Two helper methods are available for you to use. isVowel(char c) returns true if the character in c is one of the vowels in the English language (e.g. aeiou), returning false otherwise. isConsonant(char c) returns true if the character in c is not a vowel, returning false otherwise. Both are case insensitive (they work correctly for upper and lower case letters).
The two helper methods are defined in the same class as toPlural() so you can call them directly from inside the method.
noun ends in s, x, z, ch, or sh, then simply add "es" to the noun and return it.
noun ends in a consonant followed by a 'y', then replace the 'y' with 'ies'.
String class is available online.String class.Examples:
toPlural("bus") -> "buses"
toPlural("dish") -> "dishes"
toPlural("party") -> "parties"
toPlural("cat") -> "cats"
Your feedback will appear here when you check your answer.