using System; namespace calendar { class Program { static int day_1 = 14; static int month_1 = 4; static int year_1 = 2017; static int day_2 = 14; static int month_2 = 11; static int year_2 = 2021; static int increase_amount; static int TakeMonthName(string month) { switch (month.ToLower()) { case "january": return 1; case "february": return 2; case "march": return 3; case "april": return 4; case "may": return 5; case "june": return 6; case "july": return 7; case "august": return 8; case "september": return 9; case "october": return 10; case "november": return 11; case "december": return 12; default: return 0; } } static string TakeMonthInt(int month) { //for translating month name to integer switch (month) { case 1: return "january"; case 2: return "february"; case 3: return "march"; case 4: return "april"; case 5: return "may"; case 6: return "june"; case 7: return "july"; case 8: return "august"; case 9: return "september"; case 10: return "october"; case 11: return "november"; case 12: return "december"; default: return "undefined"; } } static string GetMonthsSeasons(int month) { switch (month) { case 12: case 1: case 2: return "winter"; case 3: case 4: case 5: return "spring"; case 6: case 7: case 8: return "summer"; case 9: case 10: case 11: return "autumn"; default: return "undefined"; } } static string GetDayNames(int day, int month, int year) { if (month == 1) { month = 13; year--; } if (month == 2) { month = 14; year--; } int q = day; int m = month; int k = year % 100; int j = year / 100; int h = q + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j; h = h % 7; switch (h) { case 0: return ("Saturday"); case 1: return ("Sunday"); case 2: return ("Monday"); case 3: return ("Tuesday"); case 4: return ("Wednesday"); case 5: return ("Thursday"); case 6: return ("Friday"); default: return "aaa"; } } static bool isLeapYear(int year) { if (year % 4 == 0 && year % 100 != 0) return true; else if (year % 400 == 0 && year % 4000 != 0) return true; else return false; } static int exceptDayLength(int month, int year) { if (month == 2) return isLeapYear(year) ? 29 : 28; int monthd = month % 2; if (month <= 7) return monthd == 1 ? 31 : 30; return monthd == 1 ? 30 : 31; } static void getDate1() { int day = 0; string month = "month"; int year = 0; bool isValid = false; Console.WriteLine("Getting date 1"); while (!isValid) { try { Console.WriteLine("Please enter the day as a number."); day = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please enter the month as string. "); month = Console.ReadLine(); Console.WriteLine("Please enter the year."); year = Convert.ToInt32(Console.ReadLine()); isValid = validate(day, month, year); } catch { isValid = false; } if (!isValid) { Console.WriteLine("please enter a valid date"); Console.WriteLine("Getting date 1"); } } day_1 = day; month_1 = TakeMonthName(month); year_1 = year; } static void getDate2() { int day = 0; string month = "month"; int year = 0; bool isValid = false; Console.WriteLine("Getting date 2"); while (!isValid) { try { Console.WriteLine("Please enter the day as a number."); day = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Please enter the month as string. "); month = Console.ReadLine(); Console.WriteLine("Please enter the year."); year = Convert.ToInt32(Console.ReadLine()); isValid = validate(day, month, year); } catch { isValid = false; } if (!isValid) { Console.WriteLine("please enter a valid date"); Console.WriteLine("Getting date 2"); } } day_2 = day; month_2 = TakeMonthName(month); year_2 = year; } static bool validate(int day, string month, int year) { int monthIndex = TakeMonthName(month); if (year > 10000 || year < 2015) return false; if (monthIndex == 0) return false; if (day > exceptDayLength(monthIndex, year)) return false; if (day <= 0) return false; return true; } static void checkDates() { static bool valid() { if (year_2 < year_1) return false; if (month_2 < month_1 && year_2 == year_1) return false; if (day_2 < day_1 && month_1 == month_2 && year_1 == year_2) return false; return true; } bool isValid = valid(); if (!isValid) { Console.WriteLine("the second date mus be later than first date"); getDate2(); checkDates(); } } static void printCalendar() { int extraDay = 0; string currentSeason = ""; for (int year = year_1; year <= year_2; year++) { int exceptMonth = year == year_2 ? month_2 : 12; int startMonth = year == year_1 ? month_1 : 1; for (int month = startMonth; month <= exceptMonth; month++) { if (currentSeason != GetMonthsSeasons(month)) { currentSeason = GetMonthsSeasons(month); Console.WriteLine(currentSeason); } int exceptDay = year == year_2 && month == month_2 ? day_2 : exceptDayLength(month, year); int startDay = year == year_1 && month == month_1 ? day_1 : 1; startDay += extraDay; for (int day = startDay; day <= exceptDay;) { Console.WriteLine(day + " " + TakeMonthInt(month) + " " + year + " " + GetDayNames(day, month, year)); day += increase_amount; if (day > exceptDay) { extraDay = day - exceptDay - 1; } if (day == exceptDay) { extraDay = 0; } } } } } static void Main(string[] args) { //getDate1(); //getDate2(); checkDates(); Console.WriteLine("Please enter the increase amount of the days."); increase_amount = Convert.ToInt32(Console.ReadLine()); printCalendar(); //for null days } } }