How to resolve the algorithm Day of the week step by step in the Delphi programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Day of the week step by step in the Delphi programming language
Table of Contents
Problem Statement
A company decides that whenever Xmas falls on a Sunday they will give their workers all extra paid holidays so that, together with any public holidays, workers will not have to work the following week (between the 25th of December and the first of January).
In what years between 2008 and 2121 will the 25th of December be a Sunday? Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to y2k type problems.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Day of the week step by step in the Delphi programming language
Source code in the delphi programming language
procedure IsXmasSunday(fromyear, toyear: integer);
var
i: integer;
TestDate: TDateTime;
outputyears: string;
begin
outputyears := '';
for i:= fromyear to toyear do
begin
TestDate := EncodeDate(i,12,25);
if dayofweek(TestDate) = 1 then
begin
outputyears := outputyears + inttostr(i) + ' ';
end;
end;
//CONSOLE
//writeln(outputyears);
//GUI
form1.label1.caption := outputyears;
end;
You may also check:How to resolve the algorithm Repeat a string step by step in the Suneido programming language
You may also check:How to resolve the algorithm Move-to-front algorithm step by step in the Aime programming language
You may also check:How to resolve the algorithm Order two numerical lists step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Runtime evaluation/In an environment step by step in the Go programming language
You may also check:How to resolve the algorithm Secure temporary file step by step in the C# programming language