Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
IDENTIFICATION DIVISION.
PROGRAM-ID. ISBN.
AUTHOR. Linsley Meadows.
DATE-WRITTEN. February 2019.
INSTALLATION. On-line compiler.
SECURITY. No specific security.
REMARKS. ISBN -- International Standard Book Number.
*> The purpose of this program is to take a short (10 digit) ISBN and covert it
*> to the long (13 digit) form, and vice versa.
*>
*> In printed form ISBN components are separated by hyphens which are ignored
*> in this implementation.
*>
*> The format of an ISBN is MMM-L-NNNNNNNN-C
*> where MMM is 978 (or possibly 979) to identify it as a IBN
*> L is a language code (0 or 1 for English)
*> NNNNNNNN is acombination of publisher / inprint and book number.
*> these 2 components are of variable length
*> C is a check digit (0-9 in the long version, and 0-9,X n the short)
*> The shirt versuin excludes the MMM component.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. ON-LINE.
OBJECT-COMPUTER. ON-LINE.
DATA DIVISION.
WORKING-STORAGE SECTION.
*> INDICATORS, SUBSBRIPTS ETC.
77 CONVERSION-TYPE PIC A.
88 CONVERT-TO-13 VALUE "L", "l".
88 CONVERT-TO-10 VALUE "S", "s".
88 STOP-CONVERSIONS VALUE "X", "x".
88 VALID-CONVERSION-TYPE VALUES "X","x","L","l","s","S".
77 S PIC 99 USAGE COMP.
*> Definitions for the 2 forms of the ISBN
01 ISBN-13 PIC X(13).
01 ISBN-13-COMPONENTS REDEFINES ISBN-13 USAGE DISPLAY.
05 ISBN-13-IDENT PIC 999.
88 VALID-ISBN-13-IDENT VALUES "978", "979".
05 ISBN-13-LANGUAGE PIC 9.
05 ISBN-13-PUB-BOOK PIC 9(8).
05 ISBN-13-CHECK-DIGIT PIC 9.
88 VALID-ISBN-13-CHECK-DIGITS VALUES "1","2","3","4","5",
"6","7","8","9","0".
01 ISBN-13-CHARACTERS REDEFINES ISBN-13.
05 ISBN-13-CHAR PIC X OCCURS 13 TIMES.
01 ISBN-10 PIC X(10).
01 ISBN-10-COMPONENTS REDEFINES ISBN-10 USAGE DISPLAY.
05 ISBN-10-LANGUAGE PIC 9.
05 ISBN-10-PUB-BOOK PIC 9(8).
05 ISBN-10-CHECK-DIGIT PIC X.
88 VALID-ISBN-10-CHECK-DIGITS VALUES "1","2","3","4","5",
"6","7","8","9","0",
"X","x".
01 ISBN-13-CHARACTERS REDEFINES ISBN-10.
05 ISBN-10-CHAR PIC X OCCURS 10 TIMES.
PROCEDURE DIVISION.
*> Execute main loop until uuser indcates the end by entering the
*> stop code of X or x.
PERFORM MAIN-LOOP UNTIL STOP-CONVERSIONS.
STOP RUN.
MAIN-LOOP.
*>>>>>>>>>
ACCEPT CONVERSION-TYPE.
DISPLAY CONVERSION-TYPE. *> NOT REQUIRED IN LIVE VESION
EVALUATE TRUE
WHEN CONVERT-TO-13
PERFORM GENERATE-ISBN-13;
WHEN CONVERT-TO-10
PERFORM GENERATE-ISBN-10;
WHEN STOP-CONVERSIONS
CONTINUE; *> Do nothing
WHEN OTHER
DISPLAY "Invalid Conversion Type: " & CONVERSION-TYPE & " Valid values are: S, L OR X";
END-EVALUATE.
GENERATE-ISBN-13.
*>>>>>>>>>>>>>>>>
DISPLAY "CONVERT TO 13".
*> Intialise the receiving 13 character area
MOVE 978 TO ISBN-13-IDENT. *> standard book identifier
MOVE ZERO TO ISBN-13-LANGUAGE, *> 0 or 1 for English
ISBN-13-PUB-BOOK, *> Publisher & unique Book
ISBN-13-CHECK-DIGIT. *> 0-9
GENERATE-ISBN-10.
*>>>>>>>>>>>>>>>>
DISPLAY "CONVERT TO 10".
MOVE ZERO TO ISBN-10-LANGUAGE, *> 0 or 1 for English
ISBN-10-PUB-BOOK. *> Publisher & unique Book
MOVE SPACE TO ISBN-10-CHECK-DIGIT. *> 0-9, X
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more