//The following three lines are needed to get a number from the keyboard. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class YearOfThe { public static void main(String[] args) { String[] animal = { "monkey", // 0 "rooster", // 1 "dog", // 2 "pig", // 3 "rat", // 4 "ox", // 5 "tiger", // 6 "hare", // 7 "dragon", // 8 "snake", // 9 "horse", // 10 "sheep" // 11 }; System.out.print("What year were you born? "); int year = getInt(); System.out.println(year + " was the year of the " + animal[year % animal.length] + "."); } //The following 16 lines are needed to get a number from the keyboard. private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); private static int getInt() { try { return Integer.parseInt(reader.readLine()); } catch (IOException e) { System.err.println("Couldn't receive input: " + e.getMessage()); } catch (NumberFormatException e) { System.err.println(e.getMessage() + ", the characters were not a number."); } return 0; } }