Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON: Create a program that prompts the user to input a date and then calculates what day of the week that date falls on.

IN PYTHON:

Create a program that prompts the user to input a date and then calculates what day of the week that date falls on. Use Zellers Rule to calculate the day of the week based on the users input.

Given input of month/day/year: d = day of the month. m = month (specially numbered: March=3, April=4, , December = 12, January=13, February=14). If the month is January or February, subtract one from the year. C = first two digits of the year. D = last two digits of the year. Ex 1: If the date was: 2/17/2011, the values would be: d = 17, m = 14, C = 20, D = 10 Ex 2: If the date was: 3/1/2000, the values would be: d = 1, m = 3, C = 20, D = 0 Ex 3: If the date was: 1/1/2000, the values would be: d = 1, m = 13, C = 19, D = 99 weekDay = d + [((m+1)*26)/10] + D + [D/4] + [C/4] - 2*C

Values in square brackets [] mean that the result of the division should be an integer. After the weekDay value has been found, divide it by 7 and find the remainder. This value is then tied to the days of the week (0 = Saturday, 1 = Sunday, 2 = Monday). Have the user enter the date in MM/DD/YYYY format. Use string slicing (not split) to break up the input into the individual fields and convert them to ints, these values can then be used in the formula.

Use if statements to display the day of the week and the month name in the format below (dont forget that the month number and year may have changed).

Example 1: Please enter a date (MM/DD/YYYY): 02/17/2011 Your date was Thursday, February 17, 2011 Example 2: Please enter a date (MM/DD/YYYY): 03/01/2000 Your date was Wednesday, March 1, 2000 Example 3: Please enter a date (MM/DD/YYYY): 01/01/2000 Your date was Saturday, January 1, 2000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Database Technology Management For The Year 2000

Authors: Alan Simon

1st Edition

155860264X, 978-1558602649

More Books

Students also viewed these Databases questions