The Ada Program: easter.adb

  1 -- easter.adb:  calculation of Easter in the Gregorian calendar
  2 
  3 with Ada.Text_IO, Ada.Integer_Text_IO;
  4 use Ada;
  5 
  6 procedure Easter is
  7 
  8     Year     : constant Integer := 1996;
  9     Golden   : constant Integer := (Year mod 19) + 1;
 10     Century  : constant Integer := (Year / 100) + 1;
 11     Gregorian: constant Integer := (3*Century / 4) - 12;
 12     Clavian  : constant Integer := ((8*Century + 5) / 25) - 5;
 13     Extra    : constant Integer := (5*Year / 4) - Gregorian - 10;
 14 
 15     Epact, Moon, Sunday  : Integer;
 16 
 17 begin
 18 
 19     -- Age of the calendar moon on January 1
 20     Epact := (11*Golden + 20 + Clavian - Gregorian) mod 30;
 21     if (Epact=24 or else (Epact=25 and then Golden=11)) then
 22        Epact := Epact + 1;
 23     end if;
 24 
 25     -- Day of full moon after the equinox
 26     Moon := 44 - Epact;
 27     if (Moon < 21) then
 28        Moon := Moon + 30;
 29     end if;
 30 
 31     -- Easter Sunday in days after March 1
 32     Sunday := Moon + 7 - ((Extra+Moon) mod 7);
 33 
 34     if (Sunday > 31) then
 35        Text_IO.Put ("April ");
 36        Integer_Text_IO.Put (Sunday-31);
 37     else
 38        Text_IO.Put ("March ");
 39        Integer_Text_IO.Put (Sunday);
 40     end if;
 41 
 42     Text_IO.Put (", ");
 43     Integer_Text_IO.Put (Year);
 44     Text_IO.New_Line;
 45 
 46 end Easter;