Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Given a date, it is possible to determine the day of the week for that date using the following algorithm (use integer division throughout):

image text in transcribed

2. Given a date, it is possible to determine the day of the week for that date using the following algorithm (use integer division throughout): Let y be the 4-digit year, m be a 2-digit value corresponding to the month (for example, for March m= 3, and for November m= 11), and d be the 2-digit day. If m is equal to 1 or 2 then reduce y by 1. Set p last two digits of y. Set q = first two digits of y. Set r = ((m +9) mod 12) +1. Set s= 13; -1 Set t= 1 Set u= 4. Set v = d+p+s+t+u+5q. Set w = v mod 7. The day of the week is given by the value of w, where w = 0) would be Sunday. Write a Fortran program to implement this algorithm, asking the user for the year, month and day (each in the form of a numerical value). Your code should include the following functions: FUNCTION day_name(d) that returns the name of the day for a given value of d. FUNCTION month_name(m) that returns the name of the month for a given value of m. Sample output: February 13, 2012 is a Monday. 2. Given a date, it is possible to determine the day of the week for that date using the following algorithm (use integer division throughout): Let y be the 4-digit year, m be a 2-digit value corresponding to the month (for example, for March m= 3, and for November m= 11), and d be the 2-digit day. If m is equal to 1 or 2 then reduce y by 1. Set p last two digits of y. Set q = first two digits of y. Set r = ((m +9) mod 12) +1. Set s= 13; -1 Set t= 1 Set u= 4. Set v = d+p+s+t+u+5q. Set w = v mod 7. The day of the week is given by the value of w, where w = 0) would be Sunday. Write a Fortran program to implement this algorithm, asking the user for the year, month and day (each in the form of a numerical value). Your code should include the following functions: FUNCTION day_name(d) that returns the name of the day for a given value of d. FUNCTION month_name(m) that returns the name of the month for a given value of m. Sample output: February 13, 2012 is a Monday

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

More Books

Students also viewed these Databases questions