Question: Listing 3.9 using an array of strings to store the animal names. Listing 1 import java.util.Scanner; 2 3 public class ChineseZodiac { public static void
Listing 3.9 using an array of strings to store the animal names.
Listing

1 import java.util.Scanner; 2 3 public class ChineseZodiac { public static void main(String[] args) { Scanner input = new Scanner(System.in); 4 5 System.out.print("Enter a year: "); int year = input.nextInt(); 8 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"); 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 } Enter a year: 1963 -Enter rabbit Enter a year: 1877 -Enter oX 222N 22
Step by Step Solution
3.42 Rating (161 Votes )
There are 3 Steps involved in it
Program plan o Read the year form user o Display the Chinese zodiac sign for en... View full answer
Get step-by-step solutions from verified subject matter experts
