Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:
image text in transcribed

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

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago