Day of the week of Christmas and New Year: Difference between revisions
Content added Content deleted
Jazzedpineda (talk | contribs) (Added EasyLang implementation) |
(Day of the week of Christmas and New Year in various dialects BASIC (BASIC256, QBasic, True BASIC, XBasic and Yabasic)) |
||
Line 136: | Line 136: | ||
<pre>12/25/2021 is a Saturday |
<pre>12/25/2021 is a Saturday |
||
1/ 1/2022 is a Saturday</pre> |
1/ 1/2022 is a Saturday</pre> |
||
==={{header|BASIC256}}=== |
|||
<syntaxhighlight lang="freebasic">print "Christmas Day 2021 is on a "; diasemana$(2021, 12, 25) |
|||
print "New Year's Day 2022 is on a "; diasemana$(2022, 1, 1) |
|||
end |
|||
function diasemana$(anno, mes, dia) |
|||
dim nombre$(6) |
|||
nombre$ = {"Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"} |
|||
if mes <= 2 then |
|||
mes += 12 |
|||
anno -= 1 |
|||
end if |
|||
dia = (dia-1 + ((mes+1)*26)\10 + anno + anno\4 + anno\400 + anno*6\100) mod 7 |
|||
return nombre$[dia] |
|||
end function</syntaxhighlight> |
|||
==={{header|QBasic}}=== |
|||
{{works with|QBasic|1.1}} |
|||
{{works with|QuickBasic|4.5}} |
|||
<syntaxhighlight lang="qbasic">DIM d$(6) |
|||
FOR i = 0 TO 6: READ d$(i): NEXT i |
|||
FOR i = 1 TO 2 |
|||
READ y, m, d |
|||
PRINT USING "##/##/#### is a "; m; d; y; |
|||
IF m <= 2 THEN m = m + 12: y = y - 1 |
|||
J = y \ 100 |
|||
K = y MOD 100 |
|||
d = (d + ((m + 1) * 26) \ 10 + K + K \ 4 + J \ 4 + 5 * J) MOD 7 |
|||
PRINT d$(d) |
|||
NEXT i |
|||
DATA Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday |
|||
DATA 2021, 12, 25 |
|||
DATA 2022, 1, 1 |
|||
END</syntaxhighlight> |
|||
==={{header|True BASIC}}=== |
|||
<syntaxhighlight lang="qbasic">OPTION BASE 0 |
|||
DIM d$(6) |
|||
FOR i = 0 TO 6 |
|||
READ d$(i) |
|||
NEXT i |
|||
FOR i = 1 TO 2 |
|||
READ y, m, d |
|||
PRINT USING "##/##/#### is a ": m, d, y; |
|||
IF m <= 2 THEN |
|||
LET m = m+12 |
|||
LET y = y-1 |
|||
END IF |
|||
LET j = IP(round(y)/100) |
|||
LET k = REMAINDER(ROUND(y),100) |
|||
LET d = REMAINDER(ROUND((d+IP(ROUND(((m+1)*26))/10)+k+IP(ROUND(k)/4)+IP(ROUND(j)/4)+5*j)),7) |
|||
PRINT d$(d) |
|||
NEXT i |
|||
DATA Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday |
|||
DATA 2021, 12, 25 |
|||
DATA 2022, 1, 1 |
|||
END</syntaxhighlight> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
<syntaxhighlight lang="xbasic">PROGRAM "progname" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
DIM d$[6] |
|||
d$[0] = "Saturday" |
|||
d$[1] = "Sunday" |
|||
d$[2] = "Monday" |
|||
d$[3] = "Tuesday" |
|||
d$[4] = "Wednesday" |
|||
d$[5] = "Thursday" |
|||
d$[6] = "Friday" |
|||
y = 2021: m = 12: d = 25 |
|||
FOR i = 1 TO 2 |
|||
PRINT d; " /"; m; " /"; y; " is a "; |
|||
IF m <= 2 THEN m = m + 12: y = y - 1 |
|||
J = y \ 100 |
|||
K = y MOD 100 |
|||
d = (d + ((m + 1) * 26) \ 10 + K + K \ 4 + J \ 4 + 5 * J) MOD 7 |
|||
PRINT d$[d] |
|||
y = 2022: m = 1: d = 1 |
|||
NEXT i |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
==={{header|Yabasic}}=== |
|||
<syntaxhighlight lang="yabasic">dim nombre$(6) |
|||
nombre$(0) = "Saturday" |
|||
nombre$(1) = "Sunday" |
|||
nombre$(2) = "Monday" |
|||
nombre$(3) = "Tuesday" |
|||
nombre$(4) = "Wednesday" |
|||
nombre$(5) = "Thursday" |
|||
nombre$(6) = "Friday" |
|||
print "Christmas Day 2021 is on a ", diasemana$(2021, 12, 25) |
|||
print "New Year's Day 2022 is on a ", diasemana$(2022, 1, 1) |
|||
end |
|||
sub diasemana$(anno, mes, dia) |
|||
if mes <= 2 then |
|||
mes = mes + 12 |
|||
anno = anno - 1 |
|||
fi |
|||
dia = mod((dia-1 + int(((mes+1)*26)/10) + anno + int(anno/4) + int(anno/400) + int(anno*6/100)), 7) |
|||
return nombre$(dia) |
|||
end sub</syntaxhighlight> |
|||
=={{header|BCPL}}== |
=={{header|BCPL}}== |