Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python format, please double check for errors with indentations etc. Task 3: Doomsday Algorithm, Take 4 Recall that a year's Doomsday is given by

image text in transcribed

in python format, please double check for errors with indentations etc.

Task 3: Doomsday Algorithm, Take 4 Recall that a year's Doomsday is given by the equation: Doomsday-(((yr // 12) + (yr % 12) + (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 with0 comesponding 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 tatements 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. Enter the year in four digits: 1966 2 Doomsday 1 4 Enter the year in four digits: 2019 s Doomsday-4

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 Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

how would you have done things differently?

Answered: 1 week ago

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago