ex8a - else if(remainder == 4 System.out.println"You...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//class FindZodiacSign //Tell someone their Chinese zodiac sign import java.util.Scanner; public class FindZodiacSign { public static void main (String args[]) { Scanner input = new Scanner (System.in); int year, remainder; System.out.print("Please enter your birth year: "); year = input.nextInt(); // determine which year in the cycle it is remainder = year % 12; // depending on the year in the cycle, print out the animal if (remainder == 0) System.out.println("You are the year of the Monkey."); else if (remainder == 1) System.out.println("You are the year of the Rooster."); else if (remainder == 2) System.out.println("You are the year of the Dog."); else if (remainder == 3) System.out.println("You are the year of the Pig.");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: else if (remainder == 4) System.out.println("You are the year of the Rat."); else if (remainder == 5) System.out.println("You are the year of the Ox."); else if (remainder == 6) System.out.println("You are the year of the Tiger."); else if (remainder == 7) System.out.println("You are the year of the Rabbit."); else if (remainder == 8) System.out.println("You are the year of the Dragon."); else if (remainder == 9) System.out.println("You are the year of the Snake."); else if (remainder == 10) System.out.println("You are the year of the Horse."); else if (remainder == 11) System.out.println("You are the year of the Ram."); } //end of main }//end of class FindZodiacSign...
View Full Document

This note was uploaded on 12/27/2011 for the course CMPSC 5 taught by Professor Franklin during the Fall '09 term at UCSB.

Ask a homework question - tutors are online