MuffinMonster

Class Task 6#

Oct 4th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int day, month, year;
  14.             Console.WriteLine("Please enter a date:");
  15.             Console.Write("Day: ");
  16.             day = int.Parse(Console.ReadLine());
  17.             while (day < 1 || day > 31)
  18.             {
  19.                 Console.Write("Re-enter the day so it will be vaild (1 - 31)");
  20.                 day = int.Parse(Console.ReadLine());
  21.  
  22.             }
  23.             Console.Write("Month: ");
  24.             month = int.Parse(Console.ReadLine());
  25.             while (month < 1 || month > 12)
  26.             {
  27.                 Console.Write("Re-enter the month so it will be vaid (1 - 12): ");
  28.                 month = int.Parse(Console.ReadLine());
  29.             }
  30.             Console.Write("Year: ");
  31.             year = int.Parse(Console.ReadLine());
  32.             while (year < 1900 || year > 2013)
  33.             {
  34.                 Console.Write("Re-enter the year so it will be vaild (1900 - 2013): ");
  35.                 year = int.Parse(Console.ReadLine());
  36.             }
  37.             switch (month)
  38.             {
  39.                 case 4:
  40.                 case 6:
  41.                 case 9:
  42.                 case 11: if (day > 30)
  43.                         Console.WriteLine("The day is not vaild for this month! We can not check what is the next day!"); break;
  44.                 case 2: if (day > 28)
  45.                         Console.WriteLine("The day is not vaild for this month! We can not check what is the next day!"); break;
  46.                 default: Console.WriteLine("The date is fine!"); break;
  47.             }
  48.             Console.WriteLine("The date you've typed is: " + day + "/" + month + "/" + year);
  49.             switch (day)
  50.             {
  51.                 case 29:
  52.                     switch (month)
  53.                     {
  54.                         case 2:
  55.                             day = 1;
  56.                             month++;
  57.                             Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
  58.                         break;
  59.                     }
  60.                     break;
  61.                 case 30:
  62.                     switch (month)
  63.                     {
  64.                         case 4:
  65.                         case 6:
  66.                         case 9:
  67.                         case 11:
  68.                             day = 1;
  69.                             month++;
  70.                             Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
  71.                         break;
  72.                     }
  73.                     break;
  74.                 case 31:
  75.                     switch (month)
  76.                     {
  77.                         case 1:
  78.                         case 3:
  79.                         case 5:
  80.                         case 7:
  81.                         case 8:
  82.                         case 10:
  83.                             day = 1;
  84.                             month++;
  85.                             Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
  86.                             break;
  87.                         case 12:
  88.                             day = 1;
  89.                             month = 1;
  90.                             year++;
  91.                             Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
  92.                             break;
  93.                            
  94.                     }
  95.                     break;
  96.                 default:
  97.                     day++;
  98.                     Console.WriteLine("The next day is " + day + "/" + "/" + month + "/" + year);
  99.                     break;
  100.             }
  101.             Console.ReadKey();
  102.         }
  103.     }
  104. }
Add Comment
Please, Sign In to add comment