CIS71 Lab 11 - Noun Plurals (Strings) DUE: noon, Apr 14, 2006
Scope:
String manipulation
Reading: Chapter 9
PartA: Write a function: void
plurals(char * noun, char * plural) that takes an input word (noun) and outputs
its plural (plural) on the basis of these rules:
a. If the noun ends in y, remove the y and add ies
b. If the noun ends in s, ch,
or sh, add es
c. In all other cases, just add s
PartB:
Using the plurals
function from PartA, write a program which, in a loop:
1. Prompts and reads an input string
2. Passes the string for processing to a function, which
returns another string
3. Outputs the returned string
4. Prompts the user to do another
The loop continues as long as the user responds y to the do
another request.
Sample Output:
Supply noun:chair
The plural is:chairs
Do Another (y/n)?y
Supply noun:dairy
The plural is:dairies
Do Another (y/n)?y
Supply noun:boss
The plural is:bosses
Do Another (y/n)?y
Supply noun:circus
The plural is:circuses
Do Another (y/n)?y
Supply noun:fly
The plural is:flies
Do Another (y/n)?y
Supply noun:dog
The plural is:dogs
Do Another (y/n)?y
Supply noun:church
The plural is:churches
Do Another (y/n)?y
Supply noun:clue
The plural is:clues
Do Another (y/n)?y
Supply noun:dish
The plural is:dishes
Do Another (y/n)?n
Press any key to continue