Question: Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to

Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to enter a month, day, and year. The program will then display the day of the week (Sunday..Saturday). The following example shows what the user will see on the screen: This program calculates the day of the week for any dates. Enter month (1-12): 9 Enter day (1-31): 25 Enter year: 1998 The day of the week is Friday. Hint: Use Zeller's congruence to compute the day of the week. Zeller's congruence relies on the following quantities: J is the century (19, in our example) K is the year within the century (98, in our example) m is the month (9, in our example) q is the day of the month (25, in our example) The day of the week is determined by the following formula: h = (q + 26(m + 1) / 10 + K + K / 4 + J / 4 + 5J) mod 7 where the results of the divisions are truncated. The value of h will lie between 0 (Saturday) and 6 (Friday). Note: Zeller's congruence assumes that January and February are treated as months 13 and 14 of the previous year; this affects the values of K and m, and possibly the value of J. Note that the value of h does not match the desired output of the program, so some adjustment will be necessary.

Use inheritance if possible or exception handling.

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!