Advertisement
viraldim

AgeAfter10Years

Mar 7th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /* Problem 15: Write a program to read your birthday from the console and print
  2. * how old you are now and how old you will be after 10 years.*/
  3.  
  4. using System;
  5.  
  6. class AgeAfter10Years
  7. {
  8. static void Main()
  9. {
  10. Console.WriteLine("Enter your birth date(DD.MM.YYYY)");
  11. //Date time converts a string in actual date
  12. DateTime yourBirthDate = DateTime.Parse(Console.ReadLine());
  13. DateTime timeNow = DateTime.Today;
  14. //takes ruffly your current age now
  15. int currentAge = timeNow.Year - yourBirthDate.Year;
  16. //checks wich month and day you are born and adds the years you will be on this date
  17. if (timeNow.Month <= yourBirthDate.Month && timeNow.Day <= yourBirthDate.Day)
  18. {
  19. Console.WriteLine("After 10 years you will be {0}", currentAge + 9);
  20. }
  21. else
  22. {
  23. Console.WriteLine("After 10 years you will be {0}", currentAge + 10);
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement