public class ISBN_13 {
public static int checkDigit (String isbn12){
int finaldigit = 0;
int stringLength = isbn12.length();
if (stringLength!=12){
return -1;
}
try {
for (int x = 0; x < 12; x = x +1){
if (x % 2 ==1)
finaldigit = finaldigit + 3*Character.getNumericValue(isbn12.charAt(x));
else {
finaldigit = finaldigit + Character.getNumericValue(isbn12.charAt(x));
}
}
}
catch (RuntimeException e) {
return -1;
}
finaldigit = finaldigit % 10;
return 10 - finaldigit;
}
}
当我通过一个检查代码的程序运行它时(CodeJudge)它继续告诉我运行时错误,缺少类isbn 13.我的代码有问题吗?