Example: Enter your ID number to determine what zodiac you are. Switch,case exercises, the substring class uses the contact, will use to take the remainder

Source: Internet
Author: User

Console.WriteLine ("Please enter your ID number");

string x = Console.ReadLine ();

String year=x.substring (6,4);//starting from the sixth position of the ID card, intercept four, which is your year of birth

int x1 = Convert.ToInt32 (year);//The interception into the years into the X1,

string sx = "";

Switch (X1%12)//Enter a year, if the assumption is four, you can judge the year of the zodiac, and then according to the 12 zodiac arrangement, to determine the balance of 0 to 12 of which Zodiac

{

Case 0:

Sx= "Dog";

Break

Case 1:

SX = "Chicken";

Break

Case 2:

SX = "Monkey";

Break

Case 3:

SX = "Sheep";

Break

Case 4:

SX = "Horse";

Break

Case 5:

SX = "Snake";

Break

Case 6:

SX = "Dragon";

Break

Case 7:

SX = "Rabbit";

Break

Case 8:

SX = "Tiger";

Break

Case 9:

SX = "cow";

Break

Case 10:

SX = "Rat";

Break

Case 11:

SX = "Pig";

Break

Default:

SX = "Please enter the correct year";

Break

}

Console.WriteLine ("Your Zodiac is" +sx);

Console.ReadLine ();

Example: Enter your ID number to determine what zodiac you are. Switch,case exercises, the substring class uses the contact, will use to take the remainder

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.