SHARE
TWEET

Untitled

a guest Dec 9th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public boolean isValidISBN(String isbn)
  2. {
  3.         if(isbn.length() == 10)
  4.         {
  5.         int sum = 0;
  6.         int checkDigit = 0;
  7.            
  8.         if (isbn.charAt(9) == 'X')
  9.             {
  10.             checkDigit = 10;
  11.             Character.digit(isbn.charAt(9), 10);
  12.             }
  13.             for(int d = 10; d > 1; d--)
  14.             {  
  15.                     sum += d * Character.digit(isbn.charAt(d - 10), 10);
  16.             }
  17.             if((sum + checkDigit) % 11 == 0)
  18.             {
  19.                 return true;
  20.             }
  21.             else
  22.             {
  23.                     return false;
  24.             }
  25.         }
  26.         else
  27.         {
  28.         return false;
  29.         }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top