Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Write a program that reads a year from the console and checks whether it is a leap. Use DateTime.
- */
- using System;
- class LeapYear
- {
- static void Main()
- {
- int yearToCheck;
- do{
- Console.WriteLine("Enter year (1 to 9999): ");
- }while(!(int.TryParse(Console.ReadLine(), out yearToCheck) && yearToCheck>=1 && yearToCheck<=9999));
- bool result = DateTime.IsLeapYear(yearToCheck);
- if (result == false)
- {
- Console.WriteLine("{0} is not leap!",yearToCheck);
- }
- else
- {
- Console.WriteLine("{0} is leap!",yearToCheck);
- }
- Console.WriteLine();
- Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement