Judge a few days in a certain year

Source: Internet
Author: User

Console.WriteLine ("Please enter the year:"); Try            {                intYear = Convert.ToInt32 (Console.ReadLine ());//It 's possible to throw an exceptionConsole.WriteLine ("Please enter the month:"); Try                {                    intmonth = Convert.ToInt32 (Console.ReadLine ());//1-12//It 's possible to throw an exception                    if(Month >=1&& Month <= A)                    {                        intDay =0; Switch(month) { Case 1:                             Case 3:                             Case 5:                             Case 7:                             Case 8:                             Case  A: Day= to;  Break;  Case 2:                                //determine if a leap year                                if(Year%4==0) || (Year%4==0&& Year% -!=0) ) { Day= in; }                                Else{ Day= -; }                                 Break; default: Day= -;  Break; } Console.WriteLine ("{ 0} year {1} month has {2} days", year, month, day); }//if the parentheses of the Judgment                    Else{Console.WriteLine ("the month entered is not required"); }                }//the parentheses of the try month                Catch//with Month package{Console.WriteLine ("Incorrect month entered"); }            }//parentheses for try year            Catch //matching with the year try{Console.WriteLine ("the year you entered is incorrect"); } console.readkey ();

Judge a few days in a certain year

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.