#include #include using namespace std; string pluralForm(string word); string convertToLowerCase(string st); bool isVowel(char c); void stripWhitespace(string &s); int main (int argc, char * const argv[]) { string word; cout << "\n\nNew Horizons Governors School Team B\n"; cout << "Enter a word to find the plural of (lower case): "; cin >> word; stripWhitespace(word); word = convertToLowerCase(word); cout << "The plural form of " << word << " is " << pluralForm(word) << endl; return 0; } string pluralForm(string word) { switch (word[word.length() - 1]) { case 'h': if (word[word.length() - 2] == 'c' || word[word.length() - 2] == 's') return word + "es"; else return word + "s"; case 's': return word + "es"; case 'y': if (isVowel(word[word.length() - 2])) return word + "s"; else { word.erase(word.length() - 1, 1); return word + "ies"; } case 'z': if (isVowel(word[word.length() - 2])) word += "z"; return word + "es"; default: return word + "s"; } } string convertToLowerCase(string st) { for (int i = 0; i < st.length(); i++) st[i] = tolower(st[i]); return st; } bool isVowel(char c) { switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': return 1; default: return 0; } } void stripWhitespace(string &s) { for (int i = s.length() - 1; i >= 0; i--) if (s[i] == ' ') s.erase(i, 1); }