Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int? daysToBirthday = null;
- int? MonthsToBirthday = null;
- Console.WriteLine("Please Enter Your Birthday : \n");
- DateTime Birthday = DateTime.Parse(Console.ReadLine()); // Get your birtday from the console
- int result = (DateTime.Now.Year - Birthday.Year); // Calculate your age
- Console.Clear(); // Clear the console after geting your birthday
- Console.WriteLine("Your Birthday is " + Birthday);
- // Check if your birthday month is the same as now
- if (DateTime.Now.Month == Birthday.Month) // Check if your birthday month is the same as now
- {
- // If your birthday month is the same as now , check the day
- if (DateTime.Now.Day < Birthday.Day)
- {
- // If your birthday is not passed , pulls one year and print the result
- result = (result - 1);
- daysToBirthday = Birthday.Day - DateTime.Now.Day;
- }
- // Happy birthday, the day and month of birthday match exactly
- if (DateTime.Now.Day == Birthday.Day)
- daysToBirthday = 0;
- }
- // Check if your birthday month is greater than month now
- if (DateTime.Now.Month < Birthday.Month)
- {
- MonthsToBirthday = Birthday.Month - DateTime.Now.Month;
- if (MonthsToBirthday >= 1)
- {
- Console.WriteLine("Your Birthday Is After " + (MonthsToBirthday) + " Months");
- }
- // if so remove one years and show you the result
- Console.WriteLine("Your Age Now Is : " + (result - 1));
- // Just to avoid take out 1 and then add 10
- Console.WriteLine("Your Age After 10 Years Will Be : " + (result + 9));
- }
- else
- {
- // If your birthday month has passed just shows you the result
- Console.WriteLine("Your Age Now Is : " + result);
- if (daysToBirthday >= 1)
- {
- Console.WriteLine("Your Birthday Is After " + (daysToBirthday) + " Days");
- }
- if (daysToBirthday == 0)
- {
- Console.WriteLine("Your Birthday Is Today");
- }
- // Just the result + 10 years
- Console.WriteLine("Your Age After 10 Years Will Be : " + (result + 10));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement