Advertisement
Guest User

Untitled

a guest
Feb 4th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.61 KB | None | 0 0
  1.       $ SET SOURCEFORMAT"FREE"
  2. IDENTIFICATION DIVISION.
  3. PROGRAM-ID.  MileageCounter.
  4. AUTHOR.  Michael Coughlan.
  5. * Simulates a mileage counter
  6.  
  7. DATA DIVISION.
  8. WORKING-STORAGE SECTION.
  9. 01 Counters.
  10.    02 HundredsCount          PIC 99 VALUE ZEROS.
  11.    02 TensCount              PIC 99 VALUE ZEROS.
  12.    02 UnitsCount             PIC 99 VALUE ZEROS.
  13.  
  14. 01 DisplayItems.
  15.    02 PrnHunds               PIC 9.
  16.    02 PrnTens                PIC 9.
  17.    02 PrnUnits               PIC 9.
  18.  
  19. PROCEDURE DIVISION.
  20. Begin.
  21.    DISPLAY "Using an out-of-line Perform".
  22.    DISPLAY "About to start mileage counter simulation".
  23.    PERFORM CountMilage
  24.       VARYING HundredsCount FROM 0 BY 1 UNTIL HundredsCount > 9
  25.       AFTER   TensCount FROM 0 BY 1 UNTIL TensCount > 9
  26.       AFTER   UnitsCount FROM 0 BY 1 UNTIL UnitsCount > 9
  27.    DISPLAY "End of mileage counter simulation."
  28.  
  29.    DISPLAY "Now using in-line Performs"
  30.    DISPLAY "About to start mileage counter simulation".
  31.    PERFORM VARYING HundredsCount FROM 0 BY 1 UNTIL HundredsCount > 9
  32.      PERFORM VARYING TensCount FROM 0 BY 1 UNTIL TensCount > 9
  33.         PERFORM VARYING UnitsCount FROM 0 BY 1 UNTIL UnitsCount > 9
  34.            MOVE HundredsCount TO PrnHunds
  35.            MOVE TensCount     TO  PrnTens
  36.            MOVE UnitsCount    TO PrnUnits
  37.            DISPLAY PrnHunds "-" PrnTens "-" PrnUnits
  38.         END-PERFORM
  39.      END-PERFORM
  40.    END-PERFORM.
  41.    DISPLAY "End of mileage counter simulation."
  42.    STOP RUN.
  43.  
  44.  
  45. CountMilage.
  46.    MOVE HundredsCount TO PrnHunds
  47.    MOVE TensCount     TO  PrnTens
  48.    MOVE UnitsCount    TO PrnUnits
  49.    DISPLAY PrnHunds "-" PrnTens "-" PrnUnits.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement