CISC 3110 - Assignment #2 - Validating 10 Digit ISBN

Overview:

What is this assignment about? The ISBN, International Standard Book Number, is a special code printed on books. The ISBN number consists of 10 or 13 digits. The last digit is a check digit. The check digit servees to detect errors if some of the earlier digits are incorrect. We are going to validate 10 digit ISBN numbers. The first 9 digits must range from 0-9. The last digit can be either in the range 0-9 or the character X.

Now we are writing a program to check the validity of an ISBN number. As the semester progresses, we will add more features to this program.

Sketch of Program

  1. Ask the user to enter an ISBN number. Store the ISBN number in an array.
  2. Determine whether the check digit is correct.
  3. Let the user know if the ISBN number is valid or invalid.

How is the check digit computed?

The algorithm begins by summing (the first digit) + (2 * the second digit) + (3 * the third digit) + ... + (9 * the ninth digit). Then, it computes the remainder of this sum divided by 11.

Let's illustrate with an example.
To compute the check digit for ISBN 0-306-40615-?
Multiply and add 1*0 + 2*3 + 3*0 + 4*6 + 5*4 + 6*0 + 7*6 + 8*1 + 9*5 = 145 mod 11 = 2.
Thus, the check digit is 2 and the complete sequence is ISBN 0-306-40615-2.

If the result of mod 11 is 10, the check digit is an X.

How to structure your code:

NOTE: we would like to work with the first 9 digits as numeric data, while the last digit is allowed to be the character X.

Error Checking

Be sure to perform error checking. For example, report an error if the user tries to enter an ISBN number that is of an invalid length or contains invalid (i.e., non-numeric) data.

NOTE: In future assignments you will be modifying this code so it is important that you code in a way that will allow easy code reuse.