Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. public static String getZorZe(int count) {
  2.         count = Math.abs(count);
  3.         switch (count) {
  4.             case 2:
  5.             case 3:
  6.             case 4:
  7.             case 7:
  8.             case 14:
  9.             case 17:
  10.             case 40:
  11.             case 60:
  12.             case 70:
  13.             case 100:
  14.                 return "ze";
  15.             case 0:
  16.             case 200:
  17.                 return "z";
  18.         }
  19.         if (count > 100 && count < 200)
  20.             return "ze";
  21.  
  22.         int firstDigit = firstDigit(count);
  23.         // nevokalizujeme "tř"/13/30+ http://prirucka.ujc.cas.cz/?ref=111&id=770
  24.         return (firstDigit == 2 || firstDigit == 4 || firstDigit == 7) ? "ze" : "z";
  25.     }
  26.  
  27.     public static int firstDigit(int n) {
  28.         while (n < -9 || 9 < n) n /= 10;
  29.         return Math.abs(n);
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement