Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean isValidISBN(String isbn)
- {
- if(isbn.length() == 10)
- {
- int sum = 0;
- int checkDigit = 0;
- if (isbn.charAt(9) == 'X')
- {
- checkDigit = 10;
- Character.digit(isbn.charAt(9), 10);
- }
- for(int d = 10; d > 1; d--)
- {
- sum += d * Character.digit(isbn.charAt(d - 10), 10);
- }
- if((sum + checkDigit) % 11 == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment