Answer to Question #180655 in C# for Patrick Ian Kyle Mabunay

Question #180655

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” 


1
Expert's answer
2021-04-15T10:38:44-0400
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();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS