Compute the checksum digit for ISBN codes.
Practically every book that has been published during the past thirty years can be uniquely identified by its International Standard Book Number (ISBN). An example of an ISBN is
The rightmost character is known as the check digit. It can actually be calculated from the other digits, according to the following steps (as each step is stated, it will be illustrated using the example 963-10-0604-2).
Digit | 9 | 6 | 3 | 1 | 0 | 0 | 6 | 0 | 4 |
Weight | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |
The input file will contain one or more lines. Each line will contain the first 11 characters of an ISBN, starting in column 1. The input will not contain any white spaces, except for the end-of-line characters.
An example input file would be
column 11111111112 12345678901234567890 line 1:0-07-109219[EOL] 2:0-534-95054[EOL] 3:963-10-0604[EOL] 4:3-462-01666[EOL] 5:1-890880-01[EOL] :[EOF]
In the output, each incomplete ISBN from the input will be completed: the third hyphen and the check digit will have been added. The output will contain one ISBN per line, starting at column 1.
The correct output corresponding to the example input file would be
column 111111111122222222223 123456789012345678901234567890 line 1:Program 4 by team 0[EOL] 2:0-07-109219-6[EOL] 3:0-534-95054-X[EOL] 4:963-10-0604-2[EOL] 5:3-462-01666-0[EOL] 6:1-890880-01-9[EOL] 7:End of program 4 by team 0[EOL] :[EOF]