Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Zeller's Algorithm 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...

Zeller's Algorithm

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. You can assume the user enters acceptable

numeric dates.

The formula is:

G = ( [2.6M - .2] + K + D + [D/4] + [C/4] - 2C ) mod 7

A date is expressed as follows:

M = month number

March is 1 and February is 12. January and February are considered part of the

previous year. Note your program will have to adjust the month entered by the

user.

K = day of the month

C = century number

D = year number

If year = 2012 then C = 20 and D = 12.

Here are additional examples:

7 4 1776 M = 5 K = 4 C = 17 D = 76

1 17 2008 M = 11 K = 17 C = 20 D = 7 (not 8)

Test for these values plus others including your birth date.

User entry Result

1 1 1899 Sunday

3 10 2014 Monday

1 19 2000 Wednesday

2 | Page

The program should request the date values (month, day, and year). Next the program should

determine the value of G in the algorithm, and display the appropriate day of the week. The

program should loop until the user enters 0 for month. Use the pretest while structure.

Here is what your program should do:

Display a title.

Get the month, day, and year from the user.

Calculate the day of the week.

o Convert M (month) to the correct value and change year if necessary.

o Convert the year to C and D.

o You can convert the year to C and D with two math statements.

o After setting up the values for M, K, C and D, use Java operators for this formula:

G = ( [2.6M - .2] + K + D + [D/4] + [C/4] - 2C ) mod 7

If G is less than 0, add a value of 7 to G.

All variables must be declared as integers.

You need to cast the following expression as an integer: [2.6M - .2]

Display the day of the week using a switch statement.

G is the day of the week, where 0 = Sunday 4 = Thursday

1 = Monday 5 = Friday

2 = Tuesday 6 = Saturday

3 = Wednesday

Display an error message in the switch if none of the above cases are met.

Display the number of entries made by the user.

Purpose of this project

Develop Java program with the following new features:

o if statements

o switch statements

o pretest while loop

o cast operator

o integer division

o % or modulus (mod) operator

o counters 3 | Page

Here is sample output for the final version

how much would this cost?

import java.util.Scanner;public class Zeller {static String days = { "Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday",...
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question