Advertisement
Stann

NextDate

Mar 13th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.76 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 NextDate
  8. {
  9.     class NextDate
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             byte day = byte.Parse(Console.ReadLine());
  14.             byte month = byte.Parse(Console.ReadLine());
  15.             ushort year = ushort.Parse(Console.ReadLine());
  16.             bool intercalary = false;
  17.             // If year is intercalary
  18.             if (year % 4 == 0)
  19.             {
  20.                 intercalary = true;
  21.             }
  22.             else
  23.             {
  24.                 intercalary = false;
  25.             }
  26.             switch (month)
  27.             {
  28.                 //February
  29.                 case 2:
  30.                     if (intercalary == true)
  31.                     {
  32.                         if (day < 29)
  33.                         {
  34.                             day++;
  35.                         }
  36.                         else
  37.                         {
  38.                             day = 1;
  39.                             month++;
  40.                         }
  41.                     }
  42.                     else
  43.                     {
  44.                         if (day < 28)
  45.                         {
  46.                             day++;
  47.                         }
  48.                         else
  49.                         {
  50.                             day = 1;
  51.                             month++;
  52.                         }
  53.                     }
  54.                     break;
  55.                 //April, June, September, November
  56.                 case 4:
  57.                 case 6:
  58.                 case 9:
  59.                 case 11:
  60.                     if (day < 30)
  61.                     {
  62.                         day++;
  63.                     }
  64.                     else
  65.                     {
  66.                         day = 1;
  67.                         month++;
  68.                     }
  69.                     break;
  70.                 // January, March, May, July, August, October
  71.                 case 1:
  72.                 case 3:
  73.                 case 5:
  74.                 case 7:
  75.                 case 8:
  76.                 case 10:
  77.                     if (day < 31)
  78.                     {
  79.                         day++;
  80.                     }
  81.                     else
  82.                     {
  83.                         day = 1;
  84.                         month++;
  85.                     }
  86.                     break;
  87.                 //December
  88.                 case 12:
  89.                     if (day < 31)
  90.                     {
  91.                         day++;
  92.                     }
  93.                     else
  94.                     {
  95.                         day = 1;
  96.                         month = 1;
  97.                         year++;
  98.                     }
  99.                     break;
  100.             }
  101.             Console.WriteLine("{0}.{1}.{2}", day, month, year);
  102.         }
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement