Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3 - Zeller's Algorithm In 1883, German mathematician Christian Zeller devised an algorithm, popularly known as Zeller's congruence, to calculate the day of the

image text in transcribedimage text in transcribed

Part 3 - Zeller's Algorithm In 1883, German mathematician Christian Zeller devised an algorithm, popularly known as Zeller's congruence, to calculate the day of the week on which a given date will fall or fell. In this exercise you will implement the following two functions void inputDate(int *day, int *month, int *year); void calculateDay (int day, int month, int year); The user must enter the date as dd/mm/yyyy and the function inputDate stores it in the variables day,month and year. Assume that the user enters a valid date. The function calculateDay will calculate the day of the week and print it. First, the month of the year must be transformed as an integer between 1-12 where March is 1 and February is 12. Thus, if the month is Jan or Feb, the year must also be modified to the previous year (see examples below). Zeller's algorithm is defined as follows: Let A, B, C, D denote integer variables that have the following values A-the month of the year, with March having the value 1, April the value 2,..., Decem ber the value 10, and January and February being counted as months 11 and 12 of the preceding year (in which case, subtract 1 from C) B the day of the month (1, 2,3,.., 30, 31) C- the year of the century (e.g. C- 89 for the year 1989) D the century (e.g. D 19 for the year 1989) The following examples show the values of A, B, C, D for a given date. Example 1: For input date 5/12/2006 A=10, B = 5, C = 6, D = 20 Example 2: For input date 03/02/197-4 A-12, B-3, C-73, D-19 Example 3: For input date 8/1/2000 A-11, B-8,C-99, D-19 Example 4: For input date 18/3/2020 A-1, B-18, C-20, D-20 Let W, X, Y, Z, R also denote integer variables. Compute their values in the following order using integer arithmetic: W (13*A -1)/5 R- the remainder when Z is divided by 7 If the value of R is negative, then add 7 to it. At the end of the computation R is a number between 0 and 6 and is the day of the week, where 0 represents Sunday, 1 is Monday...., 6 is Saturday. Shown below are example runs of the program. Given the same user input, your output should match the output exactly, including all punctuation. Any variation from this will result in loss of marks. Example 1: Please enter a date: 10/10/2012 The day 10/10/2012 is a Wednesday. Example 2: Please enter a date: 05/02/1985 The day 5/2/1985 is a Tuesday

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago

Question

=+what kinds of policies and practices should be developed?

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago