Computer Science, asked by shefalimatta, 11 months ago

Q5. The International Standard Book Number 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:
1Xdigit; + 2Xdigit2 +3Xdigitz +4Xdigit4 + 5Xdigits + 6Xdigito+ 7Xdigit; + 8Xdigits + 9Xdigit9+
10Xdigitio is divisible by 11.
[15]
Example : For an ISBN 1401601499
Sum= 1X1 + 4X2 + OX3 +1X4 +685 +0X6+1X7+4X8+9X9+9X10=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 ask for another
ISBN number.
(iii) If the number is 10 digits, 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”.​

Answers

Answered by ashisha3p
3

Answer:

class ISBN

{

   void chek(long a)

   {

       long s=0;

       int c=0;

       long t=a;

       while(t!=0)

       {

           t=t/10;

           c++;

       }

       if(c!=10)

       System.out.println("ILLEGAL ISBN");

       else

       {

           while(a!=0)

           {

               long l=a%10;

               for(int i=10;i>=1;i--)

               {

                   s=s+(l*i);

               }

               a=a/10;

           }

           if(s%11==0)

           System.out.println("ISBN");

           else

           System.out.println("ILLEGAL ISBN");

       }

   }

}

Explanation:

Similar questions