473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ISBN converter program

1
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
Oct 1 '07 #1
3 7282
sicarie
4,677 Expert Mod 4TB
Did you have a question? Have you tried this already? Where are you stuck?
Oct 1 '07 #2
JosAH
11,448 Expert 8TB
Nice homework/assignment; I've seen worse and more boring. Good luck.

kind regards,

Jos
Oct 1 '07 #3
mattmao
121 100+
This is like my assignment for the ISBN numbers...

I cannot give you my code but here are some suggestions:

1. use fgets rather than scanf. Check manual - man fgets

2. deal with "exceeding" inputs(say, what's the maximum length of a possible valid ISBN=10 number? My answer is 20, that is 1-2-3-4-5-6-7-8-9-X\n). Any user input that is more than 20 characters should be recognized as invalid and call a function to chunk all the unread characters in keyboard buffer, then ask the user to input again.

3. when you move on to the validation method, it is better to think about the checking algorithm first rather than rushing to coding. I lost marks on this bit because I was not optimized upon the efficiency... The proper way would be: use a for loop to iterate all positions in input characters, after all chars are taken into another string, call the checking method to test:

are there any invalid chars, if so, input is invalid (use strcspn, ect)
are there exactly 10 "digit chars"? (0,1,2,...9,and X)
is there any "-" or " " that are in the wrong position?
is the x after all other digit chars?
......

Then use the calculation method to determine if the input is a valid ISBN-10

Finally call the convert method to print out the equivalent ISBN-13 string.




Honestly your assignment is more difficult than mine, so good luck...
Oct 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jon Rea | last post by:
is there a c# -> c++ code converter out there ? Hi people, I was just wondering if there is a C# to C++ converter out there. I have some working c# code and need to integrate it into a...
0
by: Max Power | last post by:
I'm having some trouble with an RTF converter called Logictran R2Net when two users access my site simultaneously. My application simply runs an SQL query (based on parameters typed by user) that...
3
by: muppadivya | last post by:
Hi, I want to write an avi to flv converter in php but i am a complete newbie to it. I would like to know the process of how a converter code is written (ie. the basic algorithm ) . Any good...
10
by: esha | last post by:
I tried several online converters. In many case they do the job, but sometimes give some mess. I think that all converters I know are old, were created for VS 2003 and do not understand new stuff...
10
by: mm | last post by:
Is there a Perl to Python converter? Or in general: a XY to Python converter? Is see, that Python is much better then Perl anyway. But for beginners, they whant to konw how is this done with...
25
by: mereba | last post by:
Hello My country Ghana is changing its currency. I want to write a small programme in C++ that can covert from the old currency into the new one. I would like this programme to run behind a simple...
3
by: hcinderela | last post by:
Hi, I am new to C++ so bear with me a little bit. I am looking at a sample program for an isbn check. The first nine digits are supposed to be multiplied by a weight, added together and then...
3
by: logaelo | last post by:
Hello all, Could anyone explain how to optimization this code? In the prosess of optimization what is the factor needed and important to know about it? Thank you very much for all. ...
4
by: Joseph | last post by:
All: I have written a program to query Amazon with ISBN and get the book details. I would like to extend so that I can read ISBN from the barcode (I will take a photo of the same using webcam or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.