Answer to Question #185379 in C# for angelo r reyes

Question #185379

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-26T14:49:56-0400
using System;

namespace Test
{
    class NounTest
    {
        static void Main()
        {
            Console.Write("Enter some noun: ");
            string noun = Console.ReadLine();
            Console.Write("The plural is '");

            if(noun.EndsWith("y"))
            {
                Console.WriteLine(noun.Remove(noun.Length - 1) + "ies'");
            }
            else
            if(noun.EndsWith("s") || noun.EndsWith("sh") || noun.EndsWith("ch"))
            {
                Console.WriteLine(noun + "es'");
            }
            else
            {
                Console.WriteLine(noun + "s'");
            }
        }
    }
}

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