home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / source / ch21 / CHAPT21H.COB < prev    next >
Text File  |  1998-09-14  |  3KB  |  85 lines

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt21h.
  4. 000031* Compute The Date Of Easter For The Given Year
  5. 000040 Environment Division.
  6. 000050 Configuration Section.
  7. 000051 Source-Computer.  IBM-PC.
  8. 000055 Object-Computer.  IBM-PC.
  9. 000056 Data Division.
  10. 000057 Working-Storage Section.
  11. 000085 01  Easter-Work-Fields.
  12. 000086     03  The-Year          Pic 9(4) Value Zeros.
  13. 000087     03  Easter-Date       Pic 9(8) Value Zeros.
  14. 000088     03  Easter-Date-X Redefines Easter-Date.
  15. 000089         05  Easter-Month  Pic 99.
  16. 000090         05  Easter-Day    Pic 99.
  17. 000091         05  Easter-Year   Pic 9(4).
  18. 000092     03  Golden-Number     Pic 9(6).
  19. 000093     03  Century           Pic 9(3).
  20. 000094     03  Skipped-Leap-Year Pic 9(6).
  21. 000095     03  Correction        Pic 9(8).
  22. 000096     03  Factor            Pic 9(8).
  23. 000097     03  Epact             Pic 9(8).
  24. 000098 01  Temp-Work             Pic 9(8).
  25. 000099 01  Temp-Work-1           Pic 9(8).
  26. 000100 Screen Section.
  27. 000101 01  Date-Entry Blank Screen Auto.
  28. 000102     03  Line 01 Column 01 Value "Enter Year: ".
  29. 000103     03  Line 01 Column 14 Pic 9(4) Using The-Year.
  30. 000104     03  Line 03 Column 01 Value "Easter is: ".
  31. 000105     03  Line 03 Column 15 Pic 99/99/9999 From Easter-Date.
  32. 000106 Procedure Division.
  33. 000159 Chapt21h-Start.
  34. 000169     Display Date-Entry
  35. 000179     Accept Date-Entry
  36. 000180     Move The-Year To Easter-Year
  37. 000181*
  38. 000182     Compute Golden-Number = Function Rem (The-Year 19)
  39. 000183     Add 1 To Golden-Number
  40. 000184*
  41. 000190     Divide The-Year By 100 Giving Century
  42. 000200     Add 1 To Century
  43. 000210*
  44. 000211     Compute Temp-Work = 3 * Century
  45. 000220     Divide Temp-Work By 4 Giving Skipped-Leap-Year
  46. 000230     Subtract 12 From Skipped-Leap-Year
  47. 000240*
  48. 000241     Compute Temp-Work = (8 * Century) + 5
  49. 000250     Divide Temp-Work By 25 Giving Correction
  50. 000260     Subtract 5 From Correction
  51. 000270*
  52. 000271     Compute Temp-Work = 5 * The-Year
  53. 000272     Divide Temp-Work By 4 Giving Factor
  54. 000273     Subtract Skipped-Leap-Year From Factor
  55. 000274     Subtract 10 From Factor
  56. 000275*
  57. 000276     Compute Temp-Work = (11 * Golden-Number) + 20
  58. 000277                        + Correction - Skipped-Leap-Year
  59. 000278     Compute Epact = Function Rem (Temp-Work 30)
  60. 000280*
  61. 000281     If Epact = 25 And Golden-Number > 11 Or
  62. 000282        Epact = 24
  63. 000283        Add 1 To Epact
  64. 000290     End-If
  65. 000300*
  66. 000310     Compute Temp-Work = 44 - Epact
  67. 000320     If Temp-Work < 21
  68. 000330        Add 30 To Temp-Work
  69. 000340     End-If
  70. 000350*
  71. 000351     Compute Temp-Work-1 = Factor + Temp-Work
  72. 000360     Compute Easter-Day =  Temp-Work + 7 -
  73. 000370             Function Rem (Temp-Work-1 7)
  74. 000380*
  75. 000390     If Easter-Day > 31
  76. 000400        Move 4 To Easter-Month
  77. 000410        Subtract 31 From Easter-Day
  78. 000420     Else
  79. 000430        Move 3 To Easter-Month
  80. 000440     End-If
  81. 000450     Move The-Year To Easter-Year
  82. 000460*
  83. 000470     Display Date-Entry
  84. 000480     Stop Run
  85. 000490     .