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 ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int day, month, year;
- Console.WriteLine("Please enter a date:");
- 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.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! We can not check what is the next day!"); break;
- case 2: if (day > 28)
- Console.WriteLine("The day is not vaild for this month! We can not check what is the next day!"); break;
- default: Console.WriteLine("The date is fine!"); break;
- }
- Console.WriteLine("The date you've typed is: " + day + "/" + month + "/" + year);
- switch (day)
- {
- case 29:
- switch (month)
- {
- case 2:
- day = 1;
- month++;
- Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
- break;
- }
- break;
- case 30:
- switch (month)
- {
- case 4:
- case 6:
- case 9:
- case 11:
- day = 1;
- month++;
- Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
- break;
- }
- break;
- case 31:
- switch (month)
- {
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- day = 1;
- month++;
- Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
- break;
- case 12:
- day = 1;
- month = 1;
- year++;
- Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
- break;
- }
- break;
- default:
- day++;
- Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
- break;
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment