Advertisement
veronikaaa86

Word Plural

Jan 23rd, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package ConditionalStattementsLoops;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6.  
  7. public class P05_WordInPlural {
  8.     public static void main(String[] args) throws IOException {
  9.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  10.  
  11.         String word = reader.readLine();
  12.  
  13.         StringBuilder build = new StringBuilder(word);
  14.  
  15.         if (word.endsWith("y")){
  16.             build = build.deleteCharAt(build.length() - 1).append("ies");
  17.         } else  if (word.endsWith("o") || word.endsWith("s") || word.endsWith("x") || word.endsWith("z")
  18.                 || word.endsWith("ch") || word.endsWith("sh")){
  19.             build = build.append("es");
  20.         } else {
  21.             build = build.append("s");
  22.         }
  23.         System.out.println(build);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement