12-30-2024, 01:17 PM
This program is used to calculate the day of the week for any day starting from 1 AD.
Code: (Select All)
Code: (Select All)
Dim As Integer y, m, d
Dim a(1 To 12) As _Unsigned _Byte
Input "year,month,day"; y, m, d
If y < 1 Then
Print "Date of invalidity"
End
End If
Data 31,28,31,30,31,30,31,31,30,31,30,31
For i = 1 To 12
Read a(i)
Next i
For i = 1 To m - 1
s = s + a(i)
Next i
n$ = Str$(y)
If Right$(n$, 2) <> "00" Then
If y Mod 4 = 0 And m > 2 Then s = s + 1
Else
If y Mod 400 = 0 And m > 2 Then s = s + 1
End If
If y < 1582 Or (y = 1582 And m <= 10 And d <= 4) Then
y = y - 1
t = (y * 365 + y \ 4 + s + d) Mod 7
Select Case t
Case 0: Print "Friday"
Case 1: Print "Saturday"
Case 2: Print "Sunday"
Case 3: Print "Monday"
Case 4: Print "Tuesday"
Case 5: Print "Wednesday"
Case 6: Print "Thursday"
End Select
ElseIf y = 1582 And m = 10 And 4 < d And d < 15 Then
Print " The date does not exist"
ElseIf y > 1582 Or (y = 1582 And m >= 10 And d > 14) Then
y = y - 1
t = (y * 365 + (y \ 4 - (y \ 100 - y \ 400)) + s + d) Mod 7
Select Case t
Case 0: Print "Sunday"
Case 1: Print "Monday"
Case 2: Print "Tuesday"
Case 3: Print "Wednesday"
Case 4: Print "Thursday"
Case 5: Print "Friday"
Case 6: Print "Saturday"
End Select
End If