Monday, November 9, 2009

Free Teacher And Student Kissing

Recurrence of the Passover version (Java)

Oggi vi propongo una versione modificata del codice postato ieri , ho eliminato qualche stringa di codice inutile per il calcolo che devo andare ad eseguire, ho modificato la formattazione dell'output ed infine ho inserito un ciclo che mi permette di calcolare la data di diversi anni che vanno da un anno x ad un anno y nel mio caso ho deciso di calcolare tutti i 916 anni che potevo calcolare con l'algoritmo precedente.

Ecco il codice:

  1. public class Pasqua916

  2. {

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

  4. {/ / algorithm for calculating the Christian 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 = 1583; / / Gregorian year between 1583 and 2499

  6. while (y ! = 2500 )

  7. {

  8. to int y = 19% ;

  9.           int b = y % 4 ;

  10.             int c = y % 7 ;

  11.             int m = 0 ;

  12.             int n = 0 ;

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

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

  15. {

  16.                 m = 22 ;

  17.                 n = 2 ;

  18.             }

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

  20.             {

  21.                 m = 23 ;

  22.                 n = 3 ;

  23.             }

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

  25.             {

  26.                 m = 23 ;

  27.                 n = 4 ;

  28.             }

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

  30.             {

  31.                 m = 24 ;

  32.                 n = 5 ;

  33.             }

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

  35.             {

  36.                 m = 24 ;

  37.                 n = 6 ;

  38.             }

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

  40.             {

  41.                 m = 25 ;

  42.                 n = 0 ;

  43.             }

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

  45.             {

  46.                 m = 26 ;

  47.                 n = 1 ;

  48.             }

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

  50.             {

  51.       m = 25 ;

  52. n = 1 ;

  53. }

  54. / / compute d and e

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

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

  57. / / calculate the days

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

  59. {

  60. ; March int d = and + + 22; / / March case

  61. System. out. Println ( and + "=" March + + "/ 03" ) ;

  62. }

  63. else

  64. {

  65. int April = d + and - 9 ;

  66. if ( April == 26) / / exception April 1

  67. System. out. println (y + "= 19/04" ) ;

  68.                 else if ( aprile == 25 && e == 6 && a > 10   ) //eccezione 2 aprile

  69.             System. out. println (y + "= 18/04" ) ;

  70. else / / generic case in April

  71. System . out . println ( y + " = " + aprile + "/04" ) ;

  72.             }

  73.             y ++;

  74.       }

  75. }

  76. }



You can find here all my programs .

0 comments:

Post a Comment