Case: Enter the year, month, date, determine whether the input is correct, if not correct, re-enter until the correct format is entered.
1Console.Write ("Please enter the year:");2 3 for (; ; )4 {5 inty =int. Parse (Console.ReadLine ());6 if(Y >=0&& y <=9999)7 {8Console.Write ("Please enter the month:");9 Ten for (; ; ) One { A intm =int. Parse (Console.ReadLine ()); - if(M >0&& m <= A) - { theConsole.Write ("Please enter the date:"); - for (; ; ) - { - + intD =int. Parse (Console.ReadLine ()); - if(D >0&& D <= to) + { A if(M = =4|| m = =6|| m = =9|| m = = One) at { - if(D >0&& D <= -) - { -Console.WriteLine ("you are entering the"+ y +"years,"+ M +"months,"+ D +"Day"); - Break; - } in Else - { toConsole.Write ("your input is wrong, please re-enter:"); + } - } the Else if(M = =1|| m = =3|| m = =5|| m = =7|| m = =8|| m = =Ten|| m = = A) * { $ if(d >=0&& D <= to)Panax Notoginseng { -Console.WriteLine ("you are entering the"+ y +"years,"+ M +"months,"+ D +"Day"); the Break; + } A Else the { +Console.Write ("your input is wrong, please re-enter:"); - } $ } $ Else - { - if(Y%4==0&& y% -!=0|| Y% -==0) the { - if(D >0&& D <= in)Wuyi { theConsole.WriteLine ("you are entering the"+ y +"years,"+ M +"months,"+ D +"Day"); - Break; Wu } - Else About { $Console.Write ("your input is wrong, please re-enter:"); - } - - } A Else + { the if(D >0&& D <= -) - { $Console.WriteLine ("you are entering the"+ y +"years,"+ M +"months,"+ D +"Day"); the Break; the } the Else the { -Console.Write ("your input is wrong, please re-enter:"); in } the the } About } the } the Else the { +Console.Write ("your input is wrong, please re-enter:"); - } the }Bayi Break; the } the Else - { -Console.Write ("your input is wrong, please re-enter:"); the } the } the Break; the } - Else the { theConsole.Write ("your input is wrong, please re-enter:"); the 94 } the}
Hq-day6 C # Language Foundation for Loop judgment date