This is a lab exercise that involves using loops and strings.
Important: This lab will allow you the opportunity to explore pair programming which just means two students working on the same program at the same time at the same computer. You take turns typing and both offer ideas about what you should try next. If you choose to do this, please upload one (1) copy of the program with both of your names prominently displayed in it.
ISBN-10 numbers are ten character strings that uniquely identify an edition of a book. The first nine characters are base 10 digits. The last character (the tenth) is an encoding that is a function of the first nine digits. Your program is going to do various things with ISBN-10 numbers.
Notes: There are other formulas for calculating ISBN-10 check digits, but I insist that you use the one described here. Also, there is a newer ISBN system known as ISBN-13 that you should ignore completely for our purposes.
main
function and implementing the calc10
function.
The calc10
function takes a
string representation of an ISBN-10 number and
calculates the correct tenth digit of the number.
One formula for calculating the check (tenth)
digit of an ISBN-10 number is (1d0 + 2d1 +
3d2 + ... + 9d8) mod 11. Notice that the
input should contain 10 digits, but you only use the first 9 of them
to calculate the check digit.
In a correct ISBN-10 number, this result becomes the tenth digit of
the number. Note that the input from the user might or might not
have a correct check digit.
Note that mod 11 can result in numbers as large as 10.
If the result is 10, "X" is the correct value for the tenth digit.
Your function should return the correct tenth digit as a
string.