//Exercise 1: Capturing birthdaysConsole.Write ("Please enter your ID number:"); stringID =Console.ReadLine (); Console.WriteLine ("your birthday is:"+ ID. Substring (6,4) +"years"+ ID. Substring (Ten,2) +"Month"+ ID. Substring ( A,2) +"Day"); Console.ReadLine ();
/** Exercise 2: Determine if the mailbox format is correct * Analysis: * 1, have and can only have one @ * 2, cannot start with @ 3, cannot. End * 4, @ and. You can't lean together at least one at a. */Console.Write ("Please enter your email account:"); stringMail =Console.ReadLine (); if(Mail. Contains ("@")) { intaa = mail. IndexOf ("@"); intbb = mail. LastIndexOf ("@"); if(AA = =BB) { BOOLA = mail. StartsWith ("@"); if(!a) {stringSS =Mail. Substring (AA); if(SS. Contains (".")) { intDian = ss. IndexOf ("."); if(Dian! =1) { intHOU = ss. LastIndexOf ("."); if(Hou! = ss. Length-1) {Console.WriteLine ("the format of the input mailbox is correct! "); } Else{Console.WriteLine ("wrong input! "); } } Else{Console.WriteLine ("wrong input! "); } } Else{Console.WriteLine ("wrong input! "); } } Else{Console.WriteLine ("wrong input! "); } } Else{Console.WriteLine ("wrong input! "); } } Else{Console.WriteLine ("wrong input! "); } console.readline ();
//Exercise 3: Get the current time, add n days to print out the day of the weekDateTime date =NewDateTime (); Date=DateTime.Now; DayOfWeek Day=date. DayOfWeek; Console.WriteLine ("The current time is:"+ Date +"\ t"+Day ); Console.Write ("Please enter the number of days to increase:"); intn=int. Parse (Console.ReadLine ()); DateTime Date1=NewDateTime (); Date1=date. AddDays (n); DayOfWeek Day1=Date1. DayOfWeek; Console.WriteLine ("Increase"+ N +"days later, the time is:"+ Date1 +"\ t"+day1); Console.ReadLine ();
Exercise: C #---Class (Social Security number intercepts birthdays, validates mailboxes, DateTime)