In Chinese calendars, tiangan, dizhi, and Zodiac are arranged regularly. The sequence of tiangan is "A, B, and C, E, and Geng, Xin, Xi", and the sequence of Land support is "Zi, Yi, Mao, Chen, Wu, Wu, Wei, Chen, Wei ", the sequence of Chinese zodiac signs is "rat, ox, Tiger, Rabbit, dragon, Snake, horse, monkey, chicken, dog, and pig ". The Calculation Method of tiangan, dizhi, and Zodiac is very simple: the year minus 3 divided by 10 to get the remainder is a few, corresponding to the number of the day; the remainder of the year after dividing 3 by 12 is a number, which corresponds to the nth digit in the base. The calculation method of the Zodiac is the same as that of the base.
Public class shengxiao
{
Private Static final string MSG = "Run with an integer parameter, for example, Java shengxiao 2008 ";
Public void getinfo (INT year)
{
String STG [] = {"", "Jia", "B", "bing", "ding", "Wu", "Ji", "Geng ", "Xin", "Ren "};
String SDZ [] = {"Hai", "zi", "ugly", "Yin", "Mao", "Chen", "Si", "Wu ", "wei", "shen", "you", "shen "};
String ssx [] = {"pig", "rat", "Ox", "Tiger", "rabbit", "dragon", "snake", "horse ", "goat", "monkey", "chicken", "dog "};
Int I = (year-3) % 10;
Int J = (year-3) % 12;
System. Out. println ("input year: \ t" + year );
System. Out. println ("The days are \ t" + STG [I] + SDZ [J]);
System. Out. println ("corresponding to the Chinese zodiac: \ t" + ssx [J]);
}
Public static void main (string [] ARGs)
{
Shengxiao OBJ = new shengxiao ();
If (ARGs. Length <1)
{
System. Out. println (MSG );
Return;
}
Int iyear;
Try {iyear = integer. parseint (ARGs [0]);}
Catch (exception ERR)
{
System. Out. println (MSG );
Return;
}
OBJ. getinfo (iyear );
}
}