Advertisement
Venciity

[SoftUni C#] Introduction - 15. YourAgeAfter10 Years

Mar 7th, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. // Write a program to read your age from the console and print how old you will be after 10 years.
  2.  
  3. using System;
  4.  
  5. class DateAfter10Years
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Write your Birthday (date.month.year): ");
  10.         DateTime YourBirthDay = DateTime.Parse(Console.ReadLine());
  11.         DateTime TimeNow = DateTime.Today;
  12.  
  13.         int CurrentAge = TimeNow.Year - YourBirthDay.Year;
  14.  
  15.         if (TimeNow.Month < YourBirthDay.Month)
  16.         {
  17.                 Console.WriteLine("After 10 years you will be {0}", CurrentAge + 9);
  18.         }
  19.         else if (TimeNow.Month == YourBirthDay.Month)
  20.         {
  21.             if (TimeNow.Day > YourBirthDay.Day)
  22.             {
  23.                 Console.WriteLine("After 10 years you will be {0}", CurrentAge + 9);
  24.             }
  25.             else if (TimeNow.Day <= YourBirthDay.Day)
  26.             {
  27.                 Console.WriteLine("After 10 years you will be {0}", CurrentAge + 10);
  28.             }
  29.         }
  30.         else
  31.         {
  32.             Console.WriteLine("After then years you will be {0}", CurrentAge + 10);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement