cooljosh2k2
Technical User
In an assignment i have, i am to enter a date in the format DDMMYYYY, and its suppose to compute and display the day of the week that date falls on (based on a given algorithm). I was able to code a program that would give me the right day of the week, however, i was only able to get it to work in the format: date, month, year (with commas separating each of them). How can i get my program to read the date DDMMYYYY, without the commas.
Here's what i have coded (keep in mind i am new to this):
---------------------------------------------
PROGRAM assignment2
IMPLICIT NONE
INTEGER:: Day, Month, Year, Century, H
READ(*,*) Day,Month,Year !to read in format DD,MM,YYYY
Month = Month -2
!this accounts for unusual format for months (eg. March=01......February=12)
If (Month <= 0) Month = Month + 12
IF (Month >= 11) Year = Year - 1
Century = INT(Year / 100)
!eg. 2011 = 20
Year = MOD(Year, 100)
!eg. 2011= 11
H = INT(13 * Month - 1)/5 + Day + Year + &
(Year / 4) + (Century / 4) - 2*Century
H = MOD(H,7)
IF (MOD(H,7) < 0) H = MOD(H,7) + 7
!this will make sure our day of the week is a positive integer
write(*,*) 'Day Of the Week :',H
END PROGRAM assignment2
--------------------------------
Please help me.
Thanks
Here's what i have coded (keep in mind i am new to this):
---------------------------------------------
PROGRAM assignment2
IMPLICIT NONE
INTEGER:: Day, Month, Year, Century, H
READ(*,*) Day,Month,Year !to read in format DD,MM,YYYY
Month = Month -2
!this accounts for unusual format for months (eg. March=01......February=12)
If (Month <= 0) Month = Month + 12
IF (Month >= 11) Year = Year - 1
Century = INT(Year / 100)
!eg. 2011 = 20
Year = MOD(Year, 100)
!eg. 2011= 11
H = INT(13 * Month - 1)/5 + Day + Year + &
(Year / 4) + (Century / 4) - 2*Century
H = MOD(H,7)
IF (MOD(H,7) < 0) H = MOD(H,7) + 7
!this will make sure our day of the week is a positive integer
write(*,*) 'Day Of the Week :',H
END PROGRAM assignment2
--------------------------------
Please help me.
Thanks