Jump to content

Five weekends: Difference between revisions

no edit summary
No edit summary
Line 6,263:
Try it out online: [http://www.compileonline.com/execute_ksh_online.php compileonline.com]
 
=={{header|VBA}}==
<lang vb>
Option Explicit
 
Sub Main()
Dim y As Long, m As Long, t As String, cpt As Long, cptm As Long
For y = 1900 To 2100
t = vbNullString
For m = 1 To 12 Step 2
If m = 9 Then m = 8
If Weekday(DateSerial(y, m, 1)) = vbFriday Then
t = t & ", " & m
cptm = cptm + 1
End If
Next
If t <> "" Then
Debug.Print y & t
Else
cpt = cpt + 1
End If
Next
Debug.Print "There is " & cptm & " months with five full weekends from the year 1900 through 2100"
Debug.Print "There is " & cpt & " years which don't have months with five weekends"
End Sub</lang>
{{out}}
<pre>1901, 3
1902, 8
1903, 5
1904, 1, 7
1905, 12
1907, 3
1908, 5
1909, 1, 10
1910, 7
......
2090, 12
2092, 8
2093, 5
2094, 1, 10
2095, 7
2097, 3
2098, 8
2099, 5
2100, 1, 10
There is 201 months with five full weekends from the year 1900 through 2100
There is 29 years which don't have months with five weekends</pre>
=={{header|VBScript}}==
{{works with|Windows Script Host|*}}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.