Question: import java.util.Scanner; public class ChineseZodiac { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print(Enter a year: ); int year = input.nextInt();
import java.util.Scanner;
public class ChineseZodiac {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = input.nextInt();
switch (year % 12) {
case 0: System.out.println("monkey"); break;
case 1: System.out.println("rooster"); break;
case 2: System.out.println("dog"); break;
case 3: System.out.println("pig"); break;
case 4: System.out.println("rat"); break;
case 5: System.out.println("ox"); break;
case 6: System.out.println("tiger"); break;
case 7: System.out.println("rabbit"); break;
case 8: System.out.println("dragon"); break;
case 9: System.out.println("snake"); break;
case 10: System.out.println("horse"); break;
case 11: System.out.println("sheep"); break;
}
}
}
(Find the enemy) Every zodiac animal has an enemy. A zodiac animals enemy is at the opposite side
of the zodiac wheel (see the above figure). For example, Horses enemy is rat, and pigs enemy is
snake. To find animal Xs enemy, use the following formula:
Year of X?s enemy = Year of X + 6
Prompts the user to enter a year in the main method and create a method called enemy that will
display the name of the corresponding enemy (NOT the year of the enemy
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
