Answer:
class Main {
public static String numToText(int digit) {
String[] numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
return numbers[digit % 10];
}
public static void main(String[] args) {
for(int i=0; i<10; i++) {
System.out.println(i+" = "+numToText(i));
}
}
}
Explanation:
I clip the input on being 0-9 by taking it modulo 10. You could also create error handling for that if desired.