Skip to content

Instantly share code, notes, and snippets.

@chyiiiiiiiiiiii
Created January 16, 2016 19:18
Show Gist options
  • Save chyiiiiiiiiiiii/6f99d05243250bdee04b to your computer and use it in GitHub Desktop.
Save chyiiiiiiiiiiii/6f99d05243250bdee04b to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String animal[] = { "tiger", "rabbit", "dragon", "snake", "horse", "sheep", "monkey", "rooster", "dog", "pig","rat", "ox" };
int year = input.nextInt();
if (year >= 2010) {
int number = year - 2010;
System.out.println(animal[number % 12]);
} else {
int number = 2010 - year;
if (number == 12)
System.out.println(animal[number % 12]);
else {
System.out.println(animal[12 - number % 12]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment