Write a program that takes nouns and forms their plurals on the basis of these rules:
a. If a noun ends in “y”, remove the ”y” and add “ies”
b. If a noun ends in “s”, “ch” or “sh”, add “es”
c. In all other cases, just add “s”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Q180655
{
class Program
{
/// <summary>
/// Main method
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Console.Write("Enter the noun: ");
string noun =Console.ReadLine();
//a. If a noun ends in 'y', remove the 'y' and add 'ies'
if (noun.EndsWith("y"))
{
noun=noun.Remove(noun.Length - 1);
noun += "ies";
}//b. If a noun ends in 's', 'ch' or 'sh', add 'es'
else if (noun.EndsWith("s") || noun.EndsWith("ch") || noun.EndsWith("sh"))
{
noun += "es";
}//c. In all other cases, just add 's'
else {
noun += "s";
}
Console.WriteLine("The noun in plurals form: {0}", noun);
Console.ReadLine();
}
}
}
Comments
Leave a comment