Question: code in javaProject 2 : Zeller's Algorithm ( Zeller . java ) Write a Java program for Zeller's Algorithm, which can be used to determine

code in javaProject 2: Zeller's Algorithm
(Zeller.java)
Write a Java program for Zeller's Algorithm, which can be used to determine the day of the week for any date
in the past, present, or future.
The program should request the user to enter the date values (month, day, and year). Next, the program should
apply the algorithm (see below), and display the appropriate day of the week. The program should loop until the
user enters 0 for a month. Use the pre-test while loop with a sentinel-value structure. See Listing 4.6 from
the textbook for an example of this type of structure. Do not use any exit, break, or boolean variable.
In addition, validate that the month is between 0 and 12, and that day is between 1 and 31. Use the while loop
structure for error checking. Do not use any other method or algorithm to solve this problem. See listing 4.7
for an example of this type of loop.
Algorithm:
The formula is:
G=([2.6M-.2]+K+D+[D4]+[C4]-2C)mod7
where:
M: is the month number
K : is the day of the month
C : is the century number
D : is the year number
explanations:
M: March is considered month 1 and February is considered month 12. Therefore,
January and February are considered to be part of the previous year.
C: Is the first two digits of the year
D: Is the last two digits of the year
G : If this value is less than 0, add a value of 7 to G
You need to cast the following expression as an integer: [2.6 M-.2]
examples:
 code in javaProject 2: Zeller's Algorithm (Zeller.java) Write a Java program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!