Sunday, November 8, 2009

Best Color Shirt For Light Grey Suit

Recurrence of the Passover (Java)

Did you know that the calculation of the anniversary of one of the most important festivals such as Easter for Catholics is not a trivial matter!

Like most of the Catholic feast of Easter is also a mixture of traditions from other religions, in fact the date of Easter has to do with the Jewish Passover (which is entirely different What! remember that Jews do not believe in coming of the Messiah! therefore would have no meaning for them to celebrate the Catholic Easter), which is based on the phases of the moon.

Obviously the motion of the moon is different from Earth and from year to year x date is different! To top it off, Easter is celebrated on the Sunday following the date x!

I say only that the calculation is not trivial at all and I will only refer you to the Wikipedia page where it is described the algorithm that I used! Do not try to explain why the algorithm is already complicated by his own! I used the algorithm of Gauss semlice which is much more than the other proposed in the wikipedia page and has the advantage of indicating the exact date!

here's the code:

  1. public class Easter

  2. {

  3. public static void main ( String [ ] args )

  4. {/ / algorithm for Christian the calculation of Easter according to the Gregorian calendar (arithmetic method of Gauss) http://it.wikipedia.org/wiki/Calcolo_della_Pasqua # Metodo_aritmetico_di_Gauss

  5. int y = 2010 ; / / Gregorian year between 1583 and 2499

  6. final to int y = 19% ;

  7. final int b = y % 4 ;

  8.         final int c = y % 7 ;

  9.         int m = 24 ;

  10.         int n = 5 ;

  11.     / / assignment m and n according to the century of y

  12. if ( y> = 1583 & & y \u0026lt;= 1699)

  13. {

  14. m = 22 ;

  15.             n = 2 ;

  16.         }

  17.         else if ( y >= 1700 && y <= 1799 )

  18.         {

  19.             m = 23 ;

  20.             n = 3 ;

  21.         }

  22.         else if ( y >= 1800 && y <= 1899 )

  23.         {

  24.             m = 23 ;

  25.             n = 4 ;

  26.         }

  27.         else if ( y >= 1900 && y <= 2099 )

  28.         {

  29.             m = 24 ;

  30.             n = 5 ;

  31.         }

  32.         else if ( y >= 2100 && y <= 2199 )

  33.         {

  34.             m = 24 ;

  35.             n = 6 ;

  36.         }

  37.         else if ( y >= 2200 && y <= 2299 )

  38.         {

  39.             m = 25 ;

  40.             n = 0 ;

  41.         }

  42.         else if ( y >= 2300 && y <= 2399 )

  43.         {

  44.             m = 26 ;

  45.             n = 1 ;

  46.         }

  47.         else if ( y >= 2400 && y <= 2499 )

  48.       {

  49. m = 25 ;

  50. n = 1 ;

  51. }

  52. / / compute d and and

  53.         int d = ( 19 * a + m ) % 30 ;      

  54.         int e = ( 2 * b + 4 * c + 6 * d + n ) % 7 ;

  55.   / / calculate the days

  56. if (d + and \u0026lt; 10)

  57. {

  58. int March = d + and + 22 ; The Case March

  59. System. out. println ( "The Passover of the Gregorian year" y + + "falls on the day" + + March the month of March " ; ) ;

  60. }

  61. else

  62. {

  63. int April = d + and - 9 ;

  64. if (April == 26 ) //eccezione 1 aprile

  65.                 System . out . println ( "La pasqua dell anno gregoriano " + y + " cade nel giorno 19 del mese di aprile" ) ;

  66.           Else if ( April == 25 & & and == 6 & & to > 10 ) / / exception on April 2

  67. System. out. println ( "The Passover of the Gregorian year " + y + " falls within 18 days of April " ) ;

  68. else / / generic case in April

  69. System. out. println ( "The Passover of the Gregorian year" + y + "falls on the day" + + April "April" ) ;

  70. ;}

  71. }

  72. }



If you ended up here because they're looking for the date of Passover in a year x between the 1583 and 2499, I'll just ask that calculation.

0 comments:

Post a Comment