(Find future dates) Write a program that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is 1, ..., and Saturday is 6). Also prompt the user to enter the number of days after today for a future day and display the future day of the week. Here is a sample run:
Enter today's day: 1
Enter the number of days elapsed since today: 3
Today is Monday and the future day is Thursday
#Prompt the user to give input
print("Enter todays date: ")
date = int(input())
print("Enter the number of days elapsed since today: ")
elapsed = int(input())
future_date = int((date + elapsed) % 7)
day_of_week = ""
#using Switch case from dictionaries
switcher={0:"Sunday",
1: "Monday",
2:"Tuesday",
3:"Wednesday",
4:"Thursday",
5:"Friday",
6: "Saturday"}
#Display the results
if (future_date == 0):
print("Todays is %s and the future day is Sunday"%switcher.get(date))
elif(future_date == 1):
print("Todays is %s and the future day is Monday"%switcher.get(date))
elif(future_date == 2):
print("Todays is %s and the future day is Tuesday"%switcher.get(date));
elif(future_date == 3):
print("Todays is %s and the future day is Wednesday"%switcher.get(date))
elif(future_date == 4):
print("Todays is %s and the future day is Thursday"%switcher.get(date))
elif(future_date == 5):
print("Todays is %s and the future day is Friday"%switcher.get(date));
elif(future_date == 6):
print("Todays is %s and the future day is Saturday"%switcher.get(date))
Output:
Enter todays date:
1
Enter the number of days elapsed since today:
3
Todays is Monday and the future day is Thursday