kirililchev3

WordinPlural - char, if-else

May 20th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P05WordinPlural
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string word = Console.ReadLine();
  10.             char one = word[word.Length - 1];
  11.             char two = word[word.Length - 2];
  12.  
  13.             if (one == 'y')
  14.             {
  15.                 word = word.Remove(word.Length - 1);
  16.                 Console.WriteLine(word + "ies");
  17.             }
  18.             else if (one == 'o' || one == 's' || one == 'x' || one == 'z' || (one == 'h' && two == 'c' || two == 's'))
  19.             {
  20.                 Console.WriteLine(word + "es");
  21.             } else
  22.             {
  23.                 Console.WriteLine(word + "s");
  24.             }
  25.         }
  26.  
  27.    
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment