Advertisement
CuST0M1z3

AfterTenYears

Apr 26th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class HowOldAreYou
  9. {
  10. static void Main()
  11. {
  12. Console.WriteLine("Enter your year of birth:");
  13. string yearOfBirth = Console.ReadLine();
  14. int yearOfYourBirth = int.Parse(yearOfBirth);
  15. DateTime now = DateTime.Now;
  16. int yearNow = now.Year;
  17. int yourAge = 0;
  18.  
  19. if (yearOfYourBirth > 0 && (yearOfYourBirth < yearNow))
  20. {
  21. yourAge = (yearNow - yearOfYourBirth);
  22. }
  23. else
  24. {
  25. Console.WriteLine("You enter a invalid year");
  26. }
  27.  
  28. if (yourAge > 0 && yourAge < 101)
  29. {
  30. Console.WriteLine("After 10 years, you are: " + (yourAge + 10) + " years old");
  31. }
  32. else if (yourAge > 101)
  33. {
  34. Console.WriteLine("Probably you are death or a vampire :D");
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement