Challenge 33

Description

The purpose of this challenge is to manually manipulate character arrays. This challenge converts specific English word to its plural. This challenge focuses on words that end in the letter y.

Requirements

  1. Write a program to determine the plural version of English nouns that end with the letter y.
  2. Create a void function void yplural(char after[], char before[]). This function should be case-insensitive. Do NOT cout in this function. The after array represents the plural form. The before array represents the original word.
  3. Declare a char array to hold a maximum of 50 characters to receive the user input.
  4. Ask the user to enter a string. Use cin.getline(input, 50) function call to get the string from the user, where input is a character array that receives the user input.
  5. The rule for pluralizing most English words that end with the letter y goes as follows: If the word ends with -y but the second-to-last letter is a vowel, then simply add a letter -ys to create its plural form. If the word ends with -y, but the second-to-last letter is a consonant, then the –y is replaced with –ies to create its plural form. As with most rules, there are going to be exceptions; ignore those words during your testing. See the sample interaction below for some example words.
  6. Show the pluralized word
  7. You may need to write other functions to make your code easier. It’s up to you.

Sample main()

int main()
{
  char text[50], after[50];
  cout << "Enter a word: ";
  cin.getline(text, 50);

  yplural(after, text);
  cout << "The plural of " << text << " is " << after << endl;

  return 0;
}

Sample Interaction / Output

Enter a word: attorney
The plural of attorney is attorneys

Run it again

Enter a word: nanny
The plural of nanny is nannies

Run it again

Enter a word: granny
The plural of granny is grannies

Run it again

Enter a word: donkey
The plural of donkey is donkeys

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-CHAL0012

Print Requirements