public class ISBN { private String isbn; public ISBN(String input) { isbn = input; } public boolean isValidISBN() { if (isbn.length() != 10) return false; int total = 0; int ctr = 10; int a; for(a = 0; a < isbn.length()-1; a++) { if (!Character.isDigit(isbn.charAt(a))) return false; total += ctr * Integer.parseInt(isbn.substring(a,a+1)); System.out.println(total); ctr--; } if (isbn.charAt(isbn.length()-1) == 'x') if ((total+10) % 11 == 0) return true; int d10 = total % 11; System.out.println("\n" + d10); if (Character.digit(isbn.charAt(isbn.length()-1),10) == d10) return true; System.out.println(total / d10); return false; } } import javax.swing.JOptionPane; public class ISBNDriver { public static void main (String [] args) { String input = JOptionPane.showInputDialog("Enter an ISBN"); ISBN test = new ISBN(input); if (test.isValidISBN()) System.out.println("Is a valid ISBN"); else System.out.println("Is a valid ISBN."); } }