The following information is taken from Book Industry Study Group website [http://www.bisg.org/isbn-13/]: “The ISBN (International Standard Book Number) provides a standard way to identify books in global trade. On January 1, 2007 the book industry transitioned to 13-digit ISBNs, phasing out the use of 10-digit numbers. Why did the ISBN change? The change to 13 digits was needed in order to expand the numbering capacity of the ISBN system and alleviate numbering shortages in certain areas of the world. Also, by changing the ISBN to 13 digits, the book industry has fully aligned the numbering system for books with the global GTIN identification system that is widely used to identify most other consumer goods worldwide.”
ISBN-10 is a code of 10 characters separated by dashes such as 0-670-82162-4. ISBN-10 consists of four parts: a group code, a publisher code, a code that uniquely identifies the book among the publisher’s offerings, and a check character. For the ISBN-10 0-670-82162-4, the group code is 0, which identifies the book as one from an English speaking country. The publisher code 670 identifies the book as a Viking Press publication. The code 82162 uniquely identifies the book among the Viking Press publications (Homer: The Odyssey, translated by Robert Fagles).
The new ISBN standard specifies that all ISBN-10s be assigned the prefix '978' when converted to ISBN-13s. Hence, ISBN-13 consists of five parts: the EAN prefix (currently either 978 or 979) followed by the four parts that were part of ISBN-10. However, a new check digit is recalculated as described later.
The last digit of an ISBN is a check character.
The check character for ISBN-10 is calculated as follows:
· Compute the sum of the first digit plus two times the second digit plus three times the third digit … plus nine times the ninth digit.
· Compute the remainder of this sum divided by 11. If the remainder is 10, the last character is X. Otherwise, the last character is the remainder.
For example, in case of the above ISBN-10 number, the sum is
0 + 2 * 6 + 3 * 7 + 4 * 0 + 5 * 8 + 6 * 2 + 7 * 1 + 8 * 6 + 9 * 2 = 158
The remainder when 158 is divided by 11 is 4, the last character in the ISBN
The check character for ISBN-13 is calculated as follows:
· Using the first twelve digits, multiply each digit with the weighting factor shown in the table below and find the sum of the products. 0-670-82162-4
ISBN = 9 7 8 0 6 7 0 8 2 1 6 2
Weighting Factors 1 3 1 3 1 3 1 3 1 3 1 3
Values (product) 9 + 21 + 8 + 0 + 6 + 21 + 0 + 24+ 2 + 3 + 6 + 6 = 106
· Divide the sum by 10. Here, 106 divided by 10 gives 10 with a remainder of 6.
· Subtract the remainder from 10 to get the check digit. If the remainder is 0 the check digit remains 0. In the example the remainder was 6; therefore the check digit is 10 – 6 = 4.
Hence the ISBN-10 0-670-82162-4 converts to ISBN-13 978-0-670-82162-4
Specific Instructions
In this assignment you will implement an ISBN converter that converts ISBN-10 to ISBN-13. While reading the ISBN-10 number, your program should validate the format i.e. while 0-670-862162-4, 06708621624 would be correct, 0- -670-862-1624 for example would be incorrect.
Implement a class to represent an ISBN_Converter. Following good object oriented programming practices, keep the data members private. Accessor functions should be declared to set and get the private data if needed, your overloaded input operator should preferably take care of it. You are free to use c-strings or objects of string class to store the ISBN as a string, although, the object-oriented string class is recommended. When reading the ISBN-10 number, your program should first validate the format and then convert it into ISBN-13. These should be methods of the ISBN_Converter class. Write a test program to illustrate the use of your class.
The input file is given with the data. Include all the source code (well documented) and input files and sufficient representative output.
Input file data:
0-670-82162-4
03524x5532
0374292884
0025734302
1-59308-06-38
0515105198
0-425-20-045-0
0374292883
ISBN-10 is a code of 10 characters separated by dashes such as 0-670-82162-4. ISBN-10 consists of four parts: a group code, a publisher code, a code that uniquely identifies the book among the publisher’s offerings, and a check character. For the ISBN-10 0-670-82162-4, the group code is 0, which identifies the book as one from an English speaking country. The publisher code 670 identifies the book as a Viking Press publication. The code 82162 uniquely identifies the book among the Viking Press publications (Homer: The Odyssey, translated by Robert Fagles).
The new ISBN standard specifies that all ISBN-10s be assigned the prefix '978' when converted to ISBN-13s. Hence, ISBN-13 consists of five parts: the EAN prefix (currently either 978 or 979) followed by the four parts that were part of ISBN-10. However, a new check digit is recalculated as described later.
The last digit of an ISBN is a check character.
The check character for ISBN-10 is calculated as follows:
· Compute the sum of the first digit plus two times the second digit plus three times the third digit … plus nine times the ninth digit.
· Compute the remainder of this sum divided by 11. If the remainder is 10, the last character is X. Otherwise, the last character is the remainder.
For example, in case of the above ISBN-10 number, the sum is
0 + 2 * 6 + 3 * 7 + 4 * 0 + 5 * 8 + 6 * 2 + 7 * 1 + 8 * 6 + 9 * 2 = 158
The remainder when 158 is divided by 11 is 4, the last character in the ISBN
The check character for ISBN-13 is calculated as follows:
· Using the first twelve digits, multiply each digit with the weighting factor shown in the table below and find the sum of the products. 0-670-82162-4
ISBN = 9 7 8 0 6 7 0 8 2 1 6 2
Weighting Factors 1 3 1 3 1 3 1 3 1 3 1 3
Values (product) 9 + 21 + 8 + 0 + 6 + 21 + 0 + 24+ 2 + 3 + 6 + 6 = 106
· Divide the sum by 10. Here, 106 divided by 10 gives 10 with a remainder of 6.
· Subtract the remainder from 10 to get the check digit. If the remainder is 0 the check digit remains 0. In the example the remainder was 6; therefore the check digit is 10 – 6 = 4.
Hence the ISBN-10 0-670-82162-4 converts to ISBN-13 978-0-670-82162-4
Specific Instructions
In this assignment you will implement an ISBN converter that converts ISBN-10 to ISBN-13. While reading the ISBN-10 number, your program should validate the format i.e. while 0-670-862162-4, 06708621624 would be correct, 0- -670-862-1624 for example would be incorrect.
Implement a class to represent an ISBN_Converter. Following good object oriented programming practices, keep the data members private. Accessor functions should be declared to set and get the private data if needed, your overloaded input operator should preferably take care of it. You are free to use c-strings or objects of string class to store the ISBN as a string, although, the object-oriented string class is recommended. When reading the ISBN-10 number, your program should first validate the format and then convert it into ISBN-13. These should be methods of the ISBN_Converter class. Write a test program to illustrate the use of your class.
The input file is given with the data. Include all the source code (well documented) and input files and sufficient representative output.
Input file data:
0-670-82162-4
03524x5532
0374292884
0025734302
1-59308-06-38
0515105198
0-425-20-045-0
0374292883
Comment