The way the check digit works (for a 10-digit ISBN) is that its value is calculated from the previous nine digits as follows. Assuming the first 9 digits of the ISBN are called d1 through d9, one first calculates the following value "s:"
s = (1 * d1) + (2 * d2) + ... + (8 * d8) + (9 * d9)
The check digit is always the remainder of dividing s by 11, except when the remainder is 10, the check digit is "X" instead (since using "10" would create an 11-digit ISBN).
You will write a computer program to calculate the check digit of any ISBN given the first nine digits.
When entering digits one at a time, the user should be prevented from entering a number less than 0 or greater than 9. You may assume they won't enter an arbitrary string or a floating point number, but if they enter an integer that falls outside of the range 0--9, then print an error message and ask them to re-enter that digit. Don't make them start over from the beginning of the number, however; just have them re-enter the digit they messed up on.
You may design your program in any way you see fit, though you should follow the guidelines for good programming that we've discussed in class: using comments, choosing appropriate variable names, making use of functions where appropriate, etc.
Digit? 1 Digit? 5 Digit? 8 Digit? 2 Digit? 6 Digit? 1 Digit? 6 Digit? 8 Digit? 4 Last digit of ISBN should be 1.Another run:
Digit? 0 Digit? 6 Digit? 8 Digit? 8 Digit? -1 Bad digit, re-enter please. Digit? 0 Digit? 6 Digit? 6 Digit? 7 Digit? 8 Last digit of ISBN should be X.Your code does not have to follow this exact script verbatim, but all the mentioned functionality should be there: asking for digits, printing the check digit, and not allowing digits out of range to be entered.