tribalzoid
asked on
java program for chinese horoscope...
The platform used is linux system...The program will reads in user input on birth year and prints out the corresponding
Chinese horoscope sign. The program allows a user to enquire about horoscope signs until a
sentinel value of ? is used to terminate the process. There are 12 signs in the Chinese
horoscope. The calculation of a horoscope sign is based on birth year. The 12 Chinese horoscope
signs and some of their corresponding years are given below:
Horoscope Sign Birth Year
Rat 1972, 1984, 1996?
Cow 1973, 1985, 1997?
Tiger 1974, 1986, 1998?
Rabbit 1975, 1987, 1999?
Dragon 1976, 1988, 2000?
Snake 1977, 1989, 2001?
Horse 1978, 1990, 2002?
Goat 1979, 1991, 2003?
Monkey 1980, 1992, 2004?
Rooster 1981, 1993, 2005?
Dog 1982, 1994, 2006?
Pig 1983, 1995, 2007?
I want the output to be as follow...
//
Enter your birth year: 2006
Your horoscope sign: Dog
Enter your birth year: ?
<Program terminates>
//
The year of the input does not only applies to the date shown above only... for example if the input for birth year is 1876, it shld display rat horoscope ...
Any body got any idea how to do it...
Chinese horoscope sign. The program allows a user to enquire about horoscope signs until a
sentinel value of ? is used to terminate the process. There are 12 signs in the Chinese
horoscope. The calculation of a horoscope sign is based on birth year. The 12 Chinese horoscope
signs and some of their corresponding years are given below:
Horoscope Sign Birth Year
Rat 1972, 1984, 1996?
Cow 1973, 1985, 1997?
Tiger 1974, 1986, 1998?
Rabbit 1975, 1987, 1999?
Dragon 1976, 1988, 2000?
Snake 1977, 1989, 2001?
Horse 1978, 1990, 2002?
Goat 1979, 1991, 2003?
Monkey 1980, 1992, 2004?
Rooster 1981, 1993, 2005?
Dog 1982, 1994, 2006?
Pig 1983, 1995, 2007?
I want the output to be as follow...
//
Enter your birth year: 2006
Your horoscope sign: Dog
Enter your birth year: ?
<Program terminates>
//
The year of the input does not only applies to the date shown above only... for example if the input for birth year is 1876, it shld display rat horoscope ...
Any body got any idea how to do it...
ASKER
How to do the for loop and if loop in the above logic u gave...
For the above codes, how can it detect monkey is of the certain birthyear...
For the above codes, how can it detect monkey is of the certain birthyear...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
String[] values = {"Monkey", "Rooster", "Dog", "Pig", "Rat", "Cow", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Goat"};
int yearOfBirth = 2006 // or any other value;
String value = values[yearOfBirth % 12];