ISBN

in #ita19 days ago

class IsbnVerifier {
boolean isValid(String stringToVerify) {
int sum =0;
stringToVerify = stringToVerify.replaceAll("-", "");
if (stringToVerify.length() != 10) return false;
for(int i=0; i<stringToVerify.length(); i++){
if (Character.isLetter(stringToVerify.charAt(i))){
if (i == stringToVerify.length()-1 && stringToVerify.charAt(i) =='X'){
sum += 10;
break;
}
else return false;
}
char numberToBe = stringToVerify.charAt(i);
int num = numberToBe - '0';
sum += num * (10-i);
}
return sum % 11 == 0;
}
}

Sort:  

Thank you, friend!
I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
image.png
please click it!
image.png
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)

The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.

Coin Marketplace

STEEM 0.27
TRX 0.11
JST 0.031
BTC 68118.27
ETH 3793.84
USDT 1.00
SBD 3.46