Return to Snippet

Revision: 12589
at March 19, 2009 22:54 by abwaters


Initial Code
if (isbn.length() == 13 && isbn.indexOf("978") == 0)
{
  isbn = isbn.substring(3,12);
  int xsum = 0;

  for (int i = 0; i < 9; i++)
  {
      xsum += (10 - i) * Character.getNumericValue(isbn.charAt(i));
  }

  xsum %= 11;
  xsum = 11 - xsum;

  String x_val = String.valueOf(xsum);

  switch (xsum)
  {
      case 10: x_val = "X"; break;
      case 11: x_val = "0"; break;
  }

  isbn += x_val;
}

Initial URL
http://www.eblong.com/zarf/bookscan/eantoisbn-java.txt

Initial Description

                                

Initial Title
Convert UPC to ISBN

Initial Tags

                                

Initial Language
Java