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 AgeAfter10Years
- {
- static void Main()
- {
- Console.WriteLine("Please enter your birthday (ex. DD/MM/YY): ");
- DateTime birthDay = new DateTime();
- birthDay = DateTime.Parse(Console.ReadLine());
- DateTime currentDay = DateTime.Now;
- int myAge = (DateTime.Now.Year - birthDay.Year);
- if (birthDay.Year > currentDay.Year || birthDay.Year == currentDay.Year)
- {
- Console.WriteLine("You are not born!");
- }
- else if (currentDay.DayOfYear < birthDay.DayOfYear)
- {
- myAge--;
- Console.WriteLine("After 10 years you will be {0} years old", myAge + 10);
- }
- else if (birthDay.DayOfYear == currentDay.DayOfYear)
- {
- Console.WriteLine("After 10 years you will be {0} years old", myAge + 10);
- Console.WriteLine("Happy birthday!");
- }
- else
- {
- Console.WriteLine("After 10 years you will be {0} years old.", myAge + 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement