CS303E Assignment 4

Due: Thursday, June 20 by 11 pm
File Name: zeller.py (Program name must match this exactly, including case of letters.)Value: 10 points
Submit to Assignment 4 on GradeScope via Canvas
Purpose: To practice using variables, creating expressions, and using conditional logic (if/elif/else control structures).
Limitations: You may only use the Python syntax and language features covered in the book chapters 1 - 3. Specifically you may not use loops, lists, sets, dictionaries or any other data structures. You may not use the Python datetime or calendar modules or any other module for working with dates.

Review the assignment guidelines.

Write a program that prompts the user to enter a date (day, month, and year). Your program will print out the day of the week for that date.

You do not need to validate the input. That means you can assume:

Algorithm:

This algorithm is called "Zeller's Congruence" after the person who developed it, Julius Christian Johannes Zeller, a German mathematician.

Some sample calculations: for July 31, 1929, you should get month_number = 7, day = 31,land year = 1929. For January 3, 1988, you should get month_number = 13, day_in_month = 3, and year = 1987. (Recall, we must subtract 1 from the year if the month is January or February.)

Then calculate the following quantities:

    variation_in_days_per_month = (13 * (month_number + 1)) / 5 using floor division

   leap_year_days = year / 4 + year / 400 using floor division in both cases

   century_days = year / 100 again using floor division
 
   total_days = day_in_month + variation_in_days_per_month + year + leap_year_days - century_days

   day_of_week = the remainder of total_days divided by 7

If implemented correctly, day_of_week gives the day of the week: 0 represents Saturday, 1 represents Sunday, 2 represents Monday and so on.

You can test your program using dates from this year's calendar, or days that you're familiar with (like the day you were born, if you happen to know the day of the week). You can also use an online calendar to try dates from various years.

Expected output:

Format your output so that, if the user were to enter April 1, 1999, your output would look exactly like the following:

Enter the month (for example, January, February, etc.): April
Enter the day (an integer): 1
Enter the year (an integer): 1999
The day of the week is Thursday.

More sample input and output in this file. If you think your have the output correct, but are failing tests on GradeScope it may be useful to compare the results in the file to your output using a diff (short for difference) checker. You may have an app that does this on your computer or you can use a website such as https://www.diffchecker.com/

Hint. You will be "converting" strings for the months to integers. Yes, we expect you to use an if/elif/elif...elif/else structure with many options. And then after a few calculations you will be "converting" an integer representing the day of the week back to a string. Again use multi-way selection with an if/elif/elif...elif/else structure. We will learn other ways to do this conversion, but the goal of this assignment is to practice creating multi-way conditional statements.

***************************************************************

Recall, you must include and fill out the header for the assignment and place it at the top of the program. Replace any items in <> with the proper information and  delete the <>. (Note, I am no longer requiring the number of slip days used to be included in the header.)

# File: zeller.py
# Description: <A DESCRIPTION OF YOUR PROGRAM>
# Assignment Number: 4
#
# Name: <YOUR NAME>
# EID:  <YOUR EID>
# Email: <YOUR EMAIL>
# Grader: <YOUR GRADER'S NAME Mayra OR Risha>
#
# On my honor, <YOUR NAME>, this programming assignment is my own work
# and I have not provided this code to any other student.

Recall, your grader is assigned based on your last name. See the course syllabus for your assigned grader.