Advertisement
plamen83

Untitled

Mar 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.Date_after_5_Days
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var day = int.Parse(Console.ReadLine());
  10.             var month = int.Parse(Console.ReadLine());
  11.             var dayPlusFive = day + 5;
  12.             int daysInMonth;
  13.  
  14.  
  15.             switch (month)
  16.             {
  17.                 case 02:
  18.                     daysInMonth = 28;
  19.                     break;
  20.  
  21.                 case 4:
  22.                 case 6:
  23.                 case 9:
  24.                 case 11:
  25.                     daysInMonth = 30;
  26.                     break;
  27.  
  28.                 default:
  29.                     daysInMonth = 31;
  30.                     break;
  31.          
  32.             }
  33.  
  34.  
  35.             if (dayPlusFive > daysInMonth)
  36.             {
  37.                 month += 1;
  38.  
  39.                 if (month > 12)
  40.                 {
  41.                     month -= 12;
  42.                     dayPlusFive %= daysInMonth;
  43.                     Console.WriteLine("{0}.0{1}", dayPlusFive, month);
  44.  
  45.                 }
  46.  
  47.                 else if (month < 10)
  48.                 {
  49.                     dayPlusFive %= daysInMonth;
  50.                     Console.WriteLine("{0}.0{1}", dayPlusFive, month);
  51.                 }
  52.  
  53.                 else
  54.                 {
  55.                     dayPlusFive %= daysInMonth;
  56.                     Console.WriteLine("{0}.{1}", dayPlusFive, month);
  57.                 }
  58.  
  59.             }
  60.  
  61.             else
  62.             {
  63.                 if (month > 12)
  64.                 {
  65.                     month -= 12;
  66.                     dayPlusFive %= daysInMonth;
  67.                     Console.WriteLine("{0}.0{1}", dayPlusFive, month);
  68.  
  69.                 }
  70.  
  71.                 else if (month < 10)
  72.                 {
  73.                     dayPlusFive %= daysInMonth;
  74.                     Console.WriteLine("{0}.0{1}", dayPlusFive, month);
  75.                 }
  76.  
  77.                 else
  78.                 {
  79.                     dayPlusFive %= daysInMonth;
  80.                     Console.WriteLine("{0}.{1}", dayPlusFive, month);
  81.                 }
  82.             }
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement