# Arup Guha
# 6/7/2023
# Alternate method to calculate age.

#current year that doesnt change within this program
CURYEAR = 2023

#gets input from user on thier birthday.
#int() converts the input to string.
month = int(input('Enter the month of your birthday:'))
day = int(input('Enter the day of your birthday:'))
year = int(input('Enter the year of your birthday:'))

#gets input from user on the current day.
#int() converts the input to string.
curmonth = int(input('Enter today\'s month:'))
curday = int(input('Enter today\'s day:'))

# Error checking that the class requested...

# Check month entries.
if month < 1 or month > 12 or curmonth < 1 or curmonth > 12:
    print("Sorry one of the months are invalid.")

# A future birth.
elif year > CURYEAR:
    print("The year is invalid.")

# Or a definitively invalid day.
elif day < 1 or day > 31 or curday < 1 or curday > 31:
    print("Your day is invalid.")

# Should be okay to do our calculation...
else:

    # Guess for age.
    age = CURYEAR - year

    # In these cases, subtract 1 because birthday hasn't happened.
    if month > curmonth or (month == curmonth and day > curday):
        age -= 1

    # Ta da!
    print("you are",age,"years old.")
