java - Another question, this time regarding breaking a string down for validity -


thanks bunch tip on static of folks answered! feeling little less frustrated now.

i not going ask questions step step through whole assignment, want make sure way go 1 of next tasks. have written following, compiles fine (the purpose check string make sure numeric, , user may have entered isbn number or without dashes):

     private string validateisbn(string booknum)    {       string[] book;       int j=0;       ( int i=0;i<booknum.length();i++)         if (character.isdigit(booknum.charat[i]))           booknum.charat[i]=book[j];j++; 

i haven't written next part, has allow x last digit in string (which apparently how isbn numbers work). assume if above correct (or close), need check ninth character digit or x, writing like: if book[9] isdigit() || if book[9] == "x" || if book[9] == "x";

is right (isbn numbers 10 numbers or 9 numbers , x @ end)?

the last digit of isbn-10 check digit. since method supposed check if entered isbn correct, have calculate check digit on own , compare given 1 (plus making sure characters digits).

if you're not knowing means, read validating isbn-10 section @ http://en.wikipedia.org/wiki/international_standard_book_number#check_digits

the 2001 edition of official manual of international isbn agency says isbn-10 check digit[18] — last digit of ten-digit isbn — must range 0 10 (the symbol x used instead of 10) , must such sum of ten digits, each multiplied integer weight, descending 10 1, multiple of number 11. modular arithmetic convenient calculating check digit using modulus 11. each of first 9 digits of ten-digit isbn — excluding check digit, — multiplied number in sequence 10 2, , remainder of sum, respect 11, computed. resulting remainder, plus check digit, must equal 11; therefore, check digit 11 minus remainder of sum of products.

on related note: there 13-digit isbn-13...

maybe solution might this:

remove dashes, break down string int array, compute tenth-digit (see wiki-link), if fine return input string.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -