using System; class Unlucky2 { /// /// The Unlucky program (version 2) Bishop & Horspool 2002 /// =============================== /// Finds unlucky days (Friday 13th). /// Illustrates the use of for loops to improve program structure. /// void Go() { Console.Write("Enter starting year: "); int year = int.Parse(Console.ReadLine()); bool more = true; for (DateTime date = new DateTime(year,1,13); more; date = date.AddMonths(1)) { while (date.ToString("dddd") != "Friday") { date = date.AddMonths(1); } Console.WriteLine("{0:D}", date); Console.Write(" Find another? (enter y or n) "); more = (Console.ReadLine() == "y"); } } static void Main() { new Unlucky2().Go(); } }