Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String declensionByNumber(int number, String[] words) { int wordIndex = 2; if (words.length != 3) { return null; } int num = Math.abs(number) % 100; int numX = num % 10; if (num > 10 && num < 20) { wordIndex = 2; } else if (numX > 1 && numX < 5) { wordIndex = 1; } else if (numX == 1) { wordIndex = 0; } return words[wordIndex]; } }