Advertisement
Guest User

15. Age After 10 Years

a guest
Apr 1st, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09.AgeAfterTenYears
  4. {
  5.     class AgeAfterTenYears
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.Write("Enter Your Birthday with dd.mm.yyyy format: ");
  10.             DateTime birthDay = DateTime.Parse(Console.ReadLine());
  11.             DateTime today = DateTime.Now;
  12.             int currentAge = today.Year - birthDay.Year;
  13.  
  14.             if (today.Month <= birthDay.Month && today.Day <= birthDay.Month)
  15.             {
  16.                 currentAge--;
  17.             }
  18.  
  19.             Console.WriteLine("You are currently {0} years old. You will be {1} years old after 10 years.", currentAge, currentAge + 10);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement