Question: pseudocode for the following # Function: This program determines if a date entered by the user is valid. # Input: Interactive # Output: Valid date

pseudocode for the following
# Function: This program determines if a date entered by the user is valid.
# Input: Interactive
# Output: Valid date is printed or user is alerted that an invalid date was entered.
validDate = True
MIN_YEAR =0
MIN_MONTH =1
MAX_MONTH =12
MIN_DAY =1
MAX_DAY =31
# Get the year, then the month, then the day
year = int(input("Enter the year: "))
month = int(input("Enter the month (1-12): "))
day = int(input("Enter the day (1-31): "))
# Check to be sure date is valid
if year <= MIN_YEAR: # invalid year
validDate = False
elif month < MIN_MONTH or month > MAX_MONTH: # invalid month
validDate = False
elif day < MIN_DAY or day > MAX_DAY: # invalid day
validDate = False
# Test to see if date is valid and output date and whether it is valid or not
if validDate:
print(f"{month}/{day}/{year} is a valid date.")
else:
print(f"{month}/{day}/{year} is an invalid date.")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!