Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Problem 15.* Age after 10 Years
- //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.
- using System;
- class DateAfter10YearsVariant
- {
- // VARIANT
- static void Main()
- {
- // using DateTime and its methods AddYears() for adding years to the result and Substract() -> for substract birth year and current year
- Console.Write("Enter your birthday in format(dd.mm.yyyy): ");
- DateTime yourBirthday = DateTime.Parse(Console.ReadLine());
- var result = DateTime.Today.Subtract(yourBirthday).Ticks;
- Console.WriteLine("Now you are {0} years old.", new DateTime(result).Year - 1);
- Console.WriteLine("After 10 years you will be {0} years old.", new DateTime(result).AddYears(10).Year - 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement