Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IDENTIFICATION DIVISION.
- PROGRAM-ID. 99-Bottles-of-Beer-On-The-Wall.
- DATA DIVISION.
- WORKING-STORAGE SECTION.
- 01 Counter PIC S99.
- 01 Bottles PIC Z9.
- 01 Bottles-Left PIC Z9.
- PROCEDURE DIVISION.
- PASS-AROUND-THOSE-BEERS.
- PERFORM VARYING Counter FROM 99 BY -1 UNTIL Counter = -1
- MOVE Counter to Bottles
- SUBTRACT 1 FROM Counter GIVING Bottles-Left
- DISPLAY SPACES
- EVALUATE Counter
- WHEN 0
- DISPLAY "No more bottles of beer on the wall, "
- "no more bottles of beer."
- DISPLAY "Go to the store and buy some more, "
- "99 bottles of beer on the wall."
- WHEN 1
- DISPLAY " 1 bottle of beer on the wall, "
- " 1 bottle of beer."
- DISPLAY "Take one down and pass it around, "
- "no more bottles of beer on the wall."
- WHEN 2 Thru 99
- DISPLAY Bottles " bottles of beer on the wall, "
- Bottles " bottles of beer."
- DISPLAY "Take one down and pass it around, "
- Bottles-Left " bottles of beer on the wall."
- END-EVALUATE
- END-PERFORM
- GOBACK.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement