Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- /* 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. */
- class MyAgeAfter10Years
- {
- static void Main()
- {
- Console.WriteLine("Enter your birth date:");
- DateTime birthDate;
- DateTime currentDate = DateTime.Now;
- if (DateTime.TryParse(Console.ReadLine(), out birthDate))
- {
- Console.WriteLine("You are {0} years old, after 10 years you will be {1} years old.", (currentDate.Year - birthDate.Year), (currentDate.Year - birthDate.Year + 10));
- }
- else
- {
- Console.WriteLine("You have entered not a valid birth date!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement