Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Recognize the power of service guarantees.

Answered: 1 week ago

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago