string Month, Year, Day;
Console.Write("\nInsert birth month: ");
Month = Console.ReadLine();
if (Month.Equals("null"))
{
Console.Write("Insert birth day ");
Console.Write("\nInsert birth year \n");
Console.WriteLine("BIRTH MONTH:");
Console.WriteLine("BIRTH DAY:");
Console.WriteLine("BIRTH Year:");
Console.WriteLine("BIRTHDAY:");
Console.ReadKey();
}
else
{
Console.Write("Insert birth day: ");
Day = Console.ReadLine();
Console.Write("Insert birth year: ");
Year = Console.ReadLine();
Console.WriteLine("BIRTH MONTH: {0}", Month);
Console.WriteLine("BIRTH DAY: {0}", Day);
Console.WriteLine("BIRTH YEAR: {0}", Year);
Console.WriteLine("BIRTHDAY:{0}/{1}/{2}", Month, Day, Year);
Console.WriteLine("Age: {0}", DateTime.Now.Year - Convert.ToInt32(Year));
Console.ReadKey();
the only variable that i can calculate is the year but when it comes to the month
and day it does not show correctly.
The program runs like this:
Insert birth month: 04
Insert birth day:14
Insert birth year:2000
BIRTH MONTH:04
BIRTH DAY:14
BIRTH Year:2000
BIRTHDAY:04/14/2000
AGE: 22
The program runs like that because it does not considered the day and month to execute.
The program should run like this:
Insert birth month: 04
Insert birth day:14
Insert birth year:2000
BIRTH MONTH:04
BIRTH DAY:14
BIRTH Year:2000
BIRTHDAY:04/14/2000
AGE: 21
As you can see the age is 21 because the month and day which is April 14 is being considered. any there who can help me out?
I used integer first but the "null" word is not working that's why i used string instead to work this out.
The program should run like this if i insert null work:
Insert birth month:null Insert birth day Insert birth year
BIRTH MONTH: BIRTH DAY: BIRTH Year: BIRTHDAY: AGE:
here's my concern how can i calculate age considering the Three main variable which is Month,Day and Year. Thanks in advance