Question: Day of the week. Write a java program that takes a date as input and prints the day of the week that date falls on.

Day of the week. Write a java program that takes a date as input and prints the day of

the week that date falls on. Your program should have three (3)

variables: m (month), d (day), and y (year). For m use 1 for January, 2 for February,

and so forth. Use the following formulas, for the Gregorian calendar (where / denotes

integer division):

y0 = y (14 m) / 12

x = y0 + y0/4 y0/100 + y0/400

m0 = m + 12 ((14 m) / 12) 2

d0 = (d + x + 31m0 / 12) mod 7

d0 is 0 is for Sunday, 1 for Monday, 2 Tuesday, and so on.

For example, on which day of the week was January 21, 2022?

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!