ivanov_ivan

AgeAfter10Years

Jan 20th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace AgeAfter10Years
  9. {
  10.     class AgeAfter10Years
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             DateTime birthDay = DateTime.Parse(Console.ReadLine()); // Input data in format "dd.mm.yyyy"
  15.  
  16.             DateTime currDay = DateTime.Now; // Get current Date and Time from the system
  17.  
  18.             TimeSpan result = currDay - birthDay; // Calculate the difference between current day and birth day. The result is days.
  19.  
  20.             double currentAge = Math.Truncate(result.TotalDays / 365.25D); // Convert from days to years
  21.              
  22.            
  23.             // output
  24.             Console.WriteLine("Now: {0}", currentAge );
  25.             Console.WriteLine("After 10 years: {0}",currentAge + 10);
  26.  
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment