Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp12
- {
- class Program
- {
- static void Main()
- {
- space(false, 0);
- }
- static void space(bool spaced, int amount)
- {
- int num;
- Console.WriteLine("Please enter a number representing a month of the year (Jan = 1, Feb = 2, ect.)");
- if (spaced == true)
- {
- for (int i = 0; i < amount; i++)
- Console.WriteLine("\n");
- }
- string trymonth = Console.ReadLine();
- if (int.TryParse(trymonth, out num) && int.Parse(trymonth) < 13 && int.Parse(trymonth) > 0)
- {
- int month = int.Parse(trymonth);
- year(month);
- }
- else
- {
- Console.WriteLine("Enter a valid input and try again.");
- space(true, 13);
- }
- }
- static void year(int month)
- {
- int num;
- Console.WriteLine("Please input the year you wish to search.");
- string tryyear = Console.ReadLine();
- if (int.TryParse(tryyear, out num) && int.Parse(tryyear) > -1)
- {
- int year = int.Parse(tryyear);
- testleap(month, year);
- }
- else
- {
- Console.WriteLine("Enter a valid input and try again.");
- space(true, 13
- );
- }
- }
- static void testleap(int month, int year)
- {
- if (month == 2 && year % 4 == 0)
- {
- if (year % 100 != 0 || year % 400 == 0)
- {
- Console.WriteLine("During February in " + year + " there are 29 days.");
- }
- else
- {
- notleap(month, year);
- }
- }
- else
- {
- notleap(month, year);
- }
- Console.WriteLine("Press any key to continue");
- Console.ReadKey();
- }
- static void notleap(int month, int year)
- {
- switch (month)
- {
- case 1:
- Console.WriteLine("During January in " + year + " there are 31 days.");
- break;
- case 2:
- Console.WriteLine("During February in " + year + " there are 28 days.");
- break;
- case 3:
- Console.WriteLine("During March in " + year + " there are 31 days.");
- break;
- case 4:
- Console.WriteLine("During April in " + year + " there are 30 days.");
- break;
- case 5:
- Console.WriteLine("During May in " + year + " there are 31 days.");
- break;
- case 6:
- Console.WriteLine("During June in " + year + " there are 29 days.");
- break;
- case 7:
- Console.WriteLine("During July in " + year + " there are 31 days.");
- break;
- case 8:
- Console.WriteLine("During August in " + year + " there are 31 days.");
- break;
- case 9:
- Console.WriteLine("During September in " + year + " there are 30 days.");
- break;
- case 10:
- Console.WriteLine("During October in " + year + " there are 31 days.");
- break;
- case 11:
- Console.WriteLine("During November in " + year + " there are 30 days.");
- break;
- case 12:
- Console.WriteLine("During December in " + year + " there are 31 days.");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement