Advertisement
SSkrev

Date after 10 years

Mar 26th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. class DateAfterTenYears
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Add birth date (dd.mm.yyyy)");
  8.         string birthDay = Console.ReadLine();
  9.         //-------------------------------------------------------------
  10.         //Get year from birthday
  11.         string getYear = birthDay.Substring(6);
  12.         int convYear = int.Parse(getYear);
  13.         //-------------------------------------------------------------
  14.         //Get time now
  15.         DateTime Today=DateTime.Today;
  16.         //Get year (now)
  17.         string strYear = Convert.ToString(Today);
  18.         string container1 = strYear.Substring(strYear.Length - 13);
  19.         string todayYear = container1.Substring(0,4);
  20.         int convTodayYear = int.Parse(todayYear);
  21.         //-------------------------------------------------------------
  22.         int yearsNow = convTodayYear - convYear;
  23.         Console.WriteLine("You're {0} years old.",yearsNow);
  24.         int yearsAfter = yearsNow + 10;
  25.         Console.WriteLine("After ten years you will be {0} years old.",yearsAfter);
  26.        
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement