Advertisement
LardaX

Date-After-Five-Days

Aug 9th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 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 Date_After_Five_Days
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int day = int.Parse(Console.ReadLine());
  14.             int month = int.Parse(Console.ReadLine());
  15.  
  16.             day += 5;
  17.  
  18.             if (month == 2)
  19.             {
  20.                 if (day > 28)
  21.                 {
  22.                     day = day - 28;
  23.                     month++;
  24.                 }
  25.             }
  26.             else if (month == 4 || month == 6 || month == 9 || month == 11)
  27.             {
  28.                 if (day > 30)
  29.                 {
  30.                     day = day - 30;
  31.                     month++;
  32.                 }
  33.             }
  34.             else
  35.             {
  36.                 if (day > 31)
  37.                 {
  38.                     day = day - 31;
  39.                     month++;
  40.                 }
  41.             }
  42.             if (month > 12)
  43.             {
  44.                 month = month - 12;
  45.             }
  46.             Console.WriteLine("{0}.{1}", day, month.ToString().PadLeft(2, '0'));
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement