Advertisement
Fleshian

Age after 10 years

Mar 17th, 2014
188
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. // Problem 15.  * Age after 10 Years
  4. // Write a program to read your birthday from the console and print how old you are now and how old you will be after 10 years.
  5.  
  6. class AgeAfter10Years
  7. {
  8.     static void Main()
  9.     {
  10.         Console.Write("Enter birth date in the format yyyy/mm/dd: ");
  11.         string birthDateStr = Console.ReadLine();
  12.         DateTime birthDate = DateTime.Parse(birthDateStr);
  13.         DateTime todayDate = DateTime.Now;
  14.         int age = DateTime.Now.Year - birthDate.Year;
  15.         if (todayDate.Month < birthDate.Month || (todayDate.Month == birthDate.Month && todayDate.Day < birthDate.Day))
  16.         {
  17.             age--;
  18.         }
  19.         Console.WriteLine("Your are age now is: {0}", age);
  20.         Console.WriteLine("Your age after 10 yeas: {0}", age + 10);
  21.     }
  22. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement