Question
The following algorithm will calculate the date of Easter for any year in the twentieth or twenty-first centuries for Western dates. Valid years are 1900
The following algorithm will calculate the date of Easter for any year in the twentieth or twenty-first centuries for Western dates. Valid years are 1900 to 2099. Have the user input a positive year.
Subtract 1900 from the user input year and call the difference valueD.
Divide valueD by 19 and call the remainder valueR.
Divide (7 * valueR + 1) by 19. Discard the remainder and call the quotient valueP.
Divide (11 * valueR + 4 – valueP) by 29 and call the remainder valueS.
Divide valueD by 4. Discard the remainder and call the quotient valueQ.
Divide (valueD + valueQ + 31 – valueS) by 7 and call the remainder valueT.
Easter is on (25 – valueS – valueT). If this result is greater than zero, Easter for that year occurs in April on that date.
If the result is zero or negative Easter for that year falls in March. If the result is 0, Easter for that year falls on March 31 (31 – 0). If the result is –1, Easter occurs on March 30 (31 – 1). If the result is –2, Easter occurs on March 29 (31 – 2), etc. (Hint: What happens when you subtract a negative number (-1) from a number as in (31 – (-1))?)
Assignment:
Write a program, name it “Easter.py” that will ask the user to input a year and calculate the date of Easter for that year. You may need to verify your programs accuracy by doing each step by hand then check your programs values at that point. Your program should produce a single line of output of the form:
(Western) Easter Sunday - 28 March, 1948.
Assume the user always inputs a valid year.
Once your program outputs, it should loop back to the beginning and ask the user for another year. If the user inputs a negative year, stop the program, and say “Bye…”
Some sample dates:
7th April 1901 4th April 1926 25th March 1951 18th April 1976
30th March 1902 17th April 1927 13th April 1952 10th April 1977
12th April 1903 8th April 1928 5th April 1953 26th March 1978
31st March 1929
Step by Step Solution
3.50 Rating (143 Votes )
There are 3 Steps involved in it
Step: 1
yearinputEnter a valid year between 1900 and 2099 Dintyear1900 RintD19 Pint7R119 Sint11R4P...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started