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 ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int day, month, year;
- Console.WriteLine("Please enter a date: Day, month, year (yyyy):");
- Console.Write("Day: ");
- day = int.Parse(Console.ReadLine());
- while (day < 1 || day > 31)
- {
- Console.Write("Re-enter the day so it will be vaild (1 - 31)");
- day = int.Parse(Console.ReadLine());
- }
- Console.Write("Month: ");
- month = int.Parse(Console.ReadLine());
- while (month < 1 || month > 12)
- {
- Console.Write("Re-enter the month so it will be vaid (1 - 12): ");
- month = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("REMINDER: The year can only be between 1900 to 2013");
- Console.Write("Year: ");
- year = int.Parse(Console.ReadLine());
- while (year < 1900 || year > 2013)
- {
- Console.Write("Re-enter the year so it will be vaild (1900 - 2013): ");
- year = int.Parse(Console.ReadLine());
- }
- switch (month)
- {
- case 4:
- case 6:
- case 9:
- case 11: if (day > 30)
- Console.WriteLine("The day is not vaild for this month!"); break;
- case 2: if (day > 28)
- Console.WriteLine("The day is not vaild for this month!"); break;
- default: Console.WriteLine("The date is fine!"); break;
- }
- Console.Write("The date you've typed is: " + day + "/" + month + "/" + year);
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment