Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Question 1: Zeller's Algorithm Zeller's Algorithm (https://en.wikipedia.org/wiki/Zeller%27s congruence) is a means of determining on which day of the week a date fell (or will

python
image text in transcribed
image text in transcribed
Question 1: Zeller's Algorithm Zeller's Algorithm (https://en.wikipedia.org/wiki/Zeller%27s congruence) is a means of determining on which day of the week a date fell (or will fall). In this question you will write a program that asks a user for a date (e.g. March 4, 2013) and outputs the day of the week (e.g. Monday). Ask the user to enter a month, in text (e.g. "March"). The algorithm needs the number for the month, where March is 3, April is 4, ... December is 12, January is 13, and February is 14. Call this number A. You must check that the user has entered a valid month name, and convert it to the appropriate number. If the user has not entered a valid month, ask them to try again, until they do enter a valid month. This algorithm uses January & February as months 13 and 14 of the preceding year, meaning that for those months you will need to subtract 1 from the year the user enters below. 1 Ask the user to enter the day of the month (e.g. 4). Call this number B. Confirm that the day is valid for the month that was previously entered (e.g. do not accept 30 for February). Ask the user to try again if necessary. Ask the user to enter a year. Zeller's algorithm has limitations but let's assume it works for any four-digit year (1000 to 9999). Ask the user to try again if they do not enter a four-digit year. The year should be broken into C, the year within the century (e.g. 14 for 2014), and D the century (e.g. 20 for 2014). The day of the week (0 = Saturday, 1 = Sunday, etc.) can be found as: (13 (A + 1) CD 5 +++B+C+50) mod 7 where all division is integer division (remainder discarded). Your program should convert dates as long as the user wants. Ask the user if they would like to enter another date, and repeat the above, until the user indicates they want to stop. You can verify that your program is working by looking at a calendar, such as http://www.timeanddate.com/calendar/ Sample program output (blue text is typed by the user): Please enter the month: March Please enter the day of the month: 4 Please enter the year: 2013 March 4, 2013 is a Monday Would you like to convert another date? y Please enter the month: January Please enter the day of the month: 16 Please enter the year: 1973 January 16, 1973 is a Tuesday Would you like to convert another date? n Program terminated normally

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Which will you take forward?

Answered: 1 week ago