Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 3: Doomsday Algorithm, Take 4 Recall that a year's Doomsday is given by the equation: Doomsday (( yr // 12) + (yr % 1

image text in transcribed
Task 3: Doomsday Algorithm, Take 4 Recall that a year's Doomsday is given by the equation: Doomsday (( yr // 12) + (yr % 1 2) + (yr % 12) // 4) % 7 + anchor) % 7 (1) where yr is the last two digits of the year and the anchor day is an integer between 0 and 6 with 0 corresponding to Sunday and 6 to Saturday. Previously we wrote a program to calculate a year's Doomsday that included the function calc.doom (). We then added the ability to enter a full, four-digit year in one of our programming assignments. Now we're going to extend the algorithm so that, assuming we're only considering 1900-2099, we don't need to enter the anchor day. Instead we use the first two digits of the year to determine the anchor number. Thus, in this task, Write a function set.anchor ( that takes as its parameter the first two digits of the year and returns a 2 if the digits are 20 and a 3 if the digits are 19. Use multiple if and return statements Write a function main) that prompts the user for a four-digit year (an integer), extracts the first two and last two digits of the year, calls set anchor which returns the anchor, calls calc.doom (), and prints out the Doomsday. .Use the function calc.doom () that you wrote before. You should be able to copy and paste it from one Editor window into another. Anchor days for 2000-2099 are Tuesday (2) and for 1900-1999 Wednesday (-3). Example results are shown below. 1 Enter the year in four digits: 1966 Doomsday1 4 Enter the year in four digits: 2019 s Doomsday4 Save your entire program as doom.py to folder LabS in CS111. Run the program for your TA to get credit

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago