daily pastebin goal
67%
SHARE
TWEET

COBOL 99 Beers

a guest Aug 15th, 2018 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        IDENTIFICATION DIVISION.
  2.        PROGRAM-ID. 99-Bottles-of-Beer-On-The-Wall.
  3.        DATA DIVISION.
  4.        WORKING-STORAGE SECTION.
  5.        01 Counter                      PIC S99.
  6.        01 Bottles                      PIC Z9.
  7.        01 Bottles-Left                 PIC Z9.
  8.        PROCEDURE DIVISION.
  9.          PASS-AROUND-THOSE-BEERS.
  10.            PERFORM VARYING Counter FROM 99 BY -1 UNTIL Counter = -1
  11.              MOVE Counter to Bottles
  12.              SUBTRACT 1 FROM Counter GIVING Bottles-Left
  13.              DISPLAY SPACES
  14.              EVALUATE Counter
  15.                WHEN 0
  16.                  DISPLAY "No more bottles of beer on the wall, "
  17.                          "no more bottles of beer."
  18.                  DISPLAY "Go to the store and buy some more, "
  19.                          "99 bottles of beer on the wall."
  20.                WHEN 1
  21.                  DISPLAY " 1 bottle of beer on the wall, "
  22.                          "  1 bottle of beer."
  23.                  DISPLAY "Take one down and pass it around, "
  24.                          "no more bottles of beer on the wall."
  25.                WHEN 2 Thru 99
  26.                  DISPLAY Bottles " bottles of beer on the wall, "
  27.                          Bottles " bottles of beer."
  28.                  DISPLAY "Take one down and pass it around, "
  29.                          Bottles-Left " bottles of beer on the wall."
  30.              END-EVALUATE
  31.            END-PERFORM
  32.          GOBACK.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top