How to resolve the algorithm Day of the week step by step in the ERRE programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Day of the week step by step in the ERRE 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 ERRE programming language

Source code in the erre programming language

PROGRAM DAY_OF_THE_WEEK

PROCEDURE MODULO(X,Y->RES)
   IF Y=0 THEN
      RES=X
     ELSE
      RES=X-Y*INT(X/Y)
   END IF
END PROCEDURE

PROCEDURE WD(M,D,Y->RES%)
   IF M=1 OR M=2 THEN
     M+=12
     Y-=1
   END IF
   MODULO(365*Y+INT(Y/4)-INT(Y/100)+INT(Y/400)+D+INT((153*M+8)/5),7->RES)
   RES%=RES+1.0
END PROCEDURE

BEGIN
PRINT(CHR$(12);) ! CLS
FOR YR=2008 TO 2121 DO
    WD(12,25,YR->RES%)
    IF RES%=1 THEN  ! day 1 is Sunday......
      PRINT("Dec";25;",";YR)
    END IF
END FOR
GET(K$)
END PROGRAM

  

You may also check:How to resolve the algorithm Reverse words in a string step by step in the Haskell programming language
You may also check:How to resolve the algorithm 21 game step by step in the Mathematica / Wolfram Language programming language
You may also check:How to resolve the algorithm Image noise step by step in the Racket programming language
You may also check:How to resolve the algorithm Modular inverse step by step in the CLU programming language
You may also check:How to resolve the algorithm IBAN step by step in the Common Lisp programming language