skipter icon

C# Fundamentals - Words in Plural / remove and add char

skipter | PRO | 06/02/17 07:45:29 PM UTC | 0 ⭐ | 497 👁️ | Never ⏰ | []
C# |

760 B

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            string noun = Console.ReadLine();
 
            if (noun.EndsWith("y"))
            {
                noun = noun.Remove(noun.Length - 1);
                Console.WriteLine(noun + "ies");
 
            } else if (noun.EndsWith("o") || noun.EndsWith("s") || noun.EndsWith("x") || noun.EndsWith("z") || noun.EndsWith("ch") || noun.EndsWith("sh"))
            {
                Console.WriteLine(noun + "es");
            } else
            {
                Console.WriteLine(noun + "s");
            }     
        }
    }
}

Comments