Rem Program to find the Day of week of a given date
cls:print "**** DAY OF WEEK FINDER ***"
10 Input "Enter the year(yyyy):"; year
Input "Enter the month(mm):"; month
Input "Enter the day(dd):"; day
Rem Validate the date
gosub 1000
if error = 1 then print "Invalid Date. Re-enter" : goto 10
Rem calculation to find the day of week
if month >= 3 then 20
month = month + 12 : year = year - 1
20 jd = 13 * (month + 1) \ 5 
jd = jd + year \ 4 + year \ 400
jd = jd - year \ 100 + day + year - 1
jd = jd mod 7 + 1
on jd goto 100,200,300,400,500,600,700
100 print "Sunday" : end
200 print "Monday" : end
300 print "Tuesday" : end
400 print "Wednesday" : end
500 print "Thursday" : end
600 print "Friday" : end
700 print "Saturday" : end
1000 Rem Subroutine to validate the date
if year <= 0 or month <= 0 or day <= 0 then error = 1 : return
if month > 12 then error = 1 : return
on month goto 1010,1020,1010,1040,1010,1040,1010,1010,1040,1010,1040,1010
1010 maxday = 31 : goto 1200
1020 maxday = 28
if (year mod 400 = 0) then maxday = maxday + 1
if (year mod 4 = 0 and year mod 100 <> 0) then maxday = maxday + 1
goto 1200
1040 maxday = 30
1200 if day > maxday then error = 1 : return
error = 0
return
