Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Given a date, it is possible to determine the day of the week for that date u

ID: 3589910 • Letter: 2

Question

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 Set t Set u= . Set u = d + P + s +1 + u + 51. ·Set w= u 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 inelnde the following subprograms:

Explanation / Answer

program sum
INTEGER y,m,d,p,q,r,s,t,u,v,w
READ *,y,m,d
if(m==1 .or. m==2)then
y=y-1;   
endif
p=mod(y,100);
q=y/100;
r=mod((m+9),12)+1;
s=((13*r)-1)/5;
t=p/4;
u=q/4;
v=d+p+s+t+u+(5*q);
w=mod(v,7);
PRINT *," AAAAAAAAAAAAA", w
CALL print_date(y,m,d,w)
end program sum
SUBROUTINE print_date(y,m,d,w)
IMPLICIT NONE ! Recommended  
INTEGER, INTENT(IN) :: y
INTEGER, INTENT(IN) :: m
INTEGER, INTENT(IN) :: d
INTEGER, INTENT(IN) :: w
character (len=10) :: name;
character (len=40) :: day;
character (len=40) :: result;
PRINT *," AAAAAAAAAAAAA", w
if(m==1)then
name='January';
endif
if(m==2)then
name='February';
endif
if(m==3)then
name='March';
endif
if(m==4)then
name='April';
endif
if(m==5)then
name='May';
endif
if(m==6)then
name='June';
endif
if(m==7)then
name='July';
endif
if(m==8)then
name='August';
endif
if(m==9)then
name='September';
endif
if(m==10)then
name='October';
endif
if(m==11)then
name='November';
endif
if(m==12)then
name='December';
endif
if(int(w)==0)then
day='Sunday';
endif
if(w==1)then
day='Monday';
endif
if(w==2)then
day='Tuesday';
endif
if(w==3)then
day='Wednesday';
endif
if(w==4)then
day='Thursday';
endif
if(w==5)then
day='Friday';
endif
if(w==6)then
day='Saturday';
endif
PRINT *,name,d,',','is a ',day
RETURN
END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote