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