Advertisement
stefkay

AgeAfter10Years

Aug 23rd, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. class AgeAfter10Years
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Enter your birth date: ");
  8.         DateTime bDay = DateTime.Parse(Console.ReadLine());
  9.         DateTime now = DateTime.Now;
  10.         int age = now.Year - bDay.Year;
  11.  
  12.         if (now < bDay.AddYears(age))
  13.         {
  14.             age--;
  15.         }
  16.  
  17.         Console.WriteLine("You are {0} years old.", age);
  18.         Console.WriteLine("After 10 years you will be {0} years old.", age + 10);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement