Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a date, it is possible to determine the day of the week for that date using the following algorithm (use integer division throughout) .Let

image text in transcribed

Given a date, it is possible to determine the day of the week for that date using the following algorithm (use integer division throughout) .Let y be the 4-digit year, m be a 2-digit value corresponding to the month (for example, for March m-3, and for November m-11), and d be the 2-digit day. If m is equal to 1 or 2 then reduce y by 1 Set p equal to the last two digits of y Set q equal to the first two digits of y Setr-((m+9) mod 12)+1 Set s (13r-1)/5 . Set t-p/4 Set u-q/4 . Set w y mod 7. The day of the week is given by the value of w, where w would be Sunday. Write a Python program, in a file called day_of_week.py, to implement this algorithm asking the user for the year, month and day (each in the form of a numerical value). Your program should include the following functions: getDayName(d) returns a string representation of integer day d .getMonthName(m) - returns a string representation of integer month m .getDayNum(y,m, d) returns the value of w as above . main() Your output should be formatted as below Sample output 1: Enter the 4-digit year: 1992 Enter the month as an integer: 1 Enter the day as an integer: 14 anuary 14, 1992 is a Tuesday Sample output 2 Enter the 4-digit year: 2008 Enter the month as an integer: 8 Enter the day as an integer: 22 August 22, 2008 is a Friday

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

3 How the market system answers four fundamental questions.

Answered: 1 week ago

Question

5 The mechanics of the circular flow model.

Answered: 1 week ago

Question

1 The difference between a command system and a market system.

Answered: 1 week ago