daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest Dec 25th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        >>SOURCE FORMAT IS FREE
  2. IDENTIFICATION DIVISION.
  3.    PROGRAM-ID. UPC-CHECK.
  4. ENVIRONMENT DIVISION.
  5.    CONFIGURATION SECTION.
  6.       REPOSITORY.
  7.          FUNCTION ALL INTRINSIC.
  8. DATA DIVISION.
  9.    WORKING-STORAGE SECTION.
  10.    01 INPUT-STRING PICTURE 9(11).
  11.    01 UPC-DIGITS.
  12.       02 UPC-DIGIT PICTURE 9 OCCURS 11 TIMES.
  13.    01 ITERATOR     PICTURE 9(2).
  14.    01 CHECKSUM     PICTURE 9(3).
  15. PROCEDURE DIVISION.
  16. MAIN-PROCEDURE.
  17.     DISPLAY 1 UPON ARGUMENT-NUMBER.
  18.     ACCEPT INPUT-STRING FROM ARGUMENT-VALUE.
  19.     MOVE INPUT-STRING TO UPC-DIGITS.
  20.     PERFORM VARYING ITERATOR FROM 1 BY 2 UNTIL ITERATOR IS GREATER THAN 11
  21.       ADD UPC-DIGIT(ITERATOR) TO CHECKSUM GIVING CHECKSUM
  22.     END-PERFORM.
  23.     MULTIPLY CHECKSUM BY 3 GIVING CHECKSUM.
  24.     PERFORM VARYING ITERATOR FROM 2 BY 2 UNTIL ITERATOR IS GREATER THAN 10
  25.       ADD UPC-DIGIT(ITERATOR) TO CHECKSUM GIVING CHECKSUM
  26.     END-PERFORM.
  27.     MOVE MOD(CHECKSUM,10) TO CHECKSUM.
  28.     IF CHECKSUM IS EQUAL TO 0 THEN
  29.        DISPLAY CHECKSUM
  30.     ELSE
  31.        SUBTRACT CHECKSUM FROM 10 GIVING CHECKSUM
  32.        DISPLAY CHECKSUM
  33.     END-IF.
  34.     STOP RUN.
  35. END PROGRAM UPC-CHECK.
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