Programming Examples

Java program to check given ISBN is valid or not


The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if:

1 x digit1 + 2 x digit2 + 3 x digit3 + 4 x digit4  + 5 x digit5  + 6 x digit6  + 7 x digit7 + 8 x digit8  + 9 x digit9 + 10 x digit10 is divisible by 11.

Example: 

For an ISBN 1401601499

Sum=1 x 1 + 2 x 4 + 3 x 0 + 4 x 1 + 5 x 6 + 6 x 0 + 7 x 1 + 8 x 4 + 9 x 9 + 10 x 9 = 253 which is divisible by 11.

Write a program to:

(i) Input the ISBN code as a 10-digit integer.

(ii) If the ISBN is not a 10-digit integer, output the message, "Illegal ISBN" and terminate the program.

(iii) If the number is 10-digit, extract the digits of the number and compute the sum as explained above. If the sum is divisible by 11, output the message, "Legal ISBN". If the sum is not divisible by 11, output the message, "Illegal ISBN".

Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz