Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java coding (9 pts) Problem 2 Zeller's congruence (developed by German mathematician Christian Zeller in the late 1800s) gives a way to determine the day

Java coding image text in transcribed
(9 pts) Problem 2 Zeller's congruence (developed by German mathematician Christian Zeller in the late 1800s) gives a way to determine the day of the week of any calendar date. The formula states: h = (a + b3 + 1) + x + 15 + 1 +53) mod 7 where h is the day of the week (with 0 - Saturday, 1 = Sunday, 2 = Monday, etc.), 2 is the day of the month (1-31), m is the month with 3 = March, 4 = April, 5 = May..... 12 = December, 13 = January, 14 = February), K is the year of the century (e.g., K = 19 for 2019), and J is the century (e.g., J = 20 for 2019). Note that the brackets in this expression mean "floor" - i.e., round down the result of the division to the next integer. The tricky part about this formula is that January and February are treated as the 13th and 14th months of the previous year. Here are two examples of how to apply Zeller's congruence: Example 1: July 20, 1969 q=20, m = 7, K = 69, J = 19 Using these values, Zeller's congruence yields h = 1, which corresponds to Sunday. Example 2: February 9, 2000 February is treated as the 14th month of the previous year, 1999. q=9, m = 14, K = 99, J = 19 Using these values, Zeller's congruence yields h = 4, which corresponds to Wednesday. Within your Lab2HW folder, write a program named Zeller.java that allows the user to enter the month (1-12), day (1-31), and year. The program should then use Zeller's congruence to determine and display the corresponding day of the week. You may assume that the user will enter valid input. Hint: Check the user's input to see if you need to make changes to the entered values for month and year. If the month is 1 or 2, you should replace it with 13 or 14 and also decrease the year by one. Here's an example of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running. Enter the month (1-12): 2 Enter the day of the month (1-31): 9 Enter the year: 2000 2/9/2000 is a Wednesday

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What is the economic meaning of duration?

Answered: 1 week ago