Question: 1.4.11 dayOfWeek Write the function dayofweek (month, day, year) which takes a date represented by three integers, the month (1 to 12), the day (1

 1.4.11 dayOfWeek Write the function dayofweek (month, day, year) which takes

1.4.11 dayOfWeek Write the function dayofweek (month, day, year) which takes a date represented by three integers, the month (1 to 12), the day (1 to 31), and the year, and returns an integer representing the day of the week for that date, where Sunday is 1 , Monday is 2,, and Saturday is 7. While there are several ways to do this, you must use this formula (from mathforum.org), where [value] means to take the floor of value : N=d+2m+[3(m+1)/5]+y+[y/4][y/100]+[y/400]+2 Notes: - d is the day of the month, m is the number of the month, and y is the year. - The numbers of the months January and February are 13 and 14 of the previous year. This means that to find the day of the week of New Year's day (of 1998), 1/1/98, you must use the date 13/1/97. - The remainder when you divide N by 7 is the day-of-week, where Saturday is 0 and Friday is 6 . Note that these values for the day are not quite the same as those returned by this method. Hints: 1. Pav close attention to the test case we provided calling davofWeek 10

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!