java - I asked a question about arrays before, but this one won't compile -
i asked array little while ago, , can't see problem is. tired. have done wrong? basically, taking string array , trying check see if contains numbers or x (isbn number validation). want take number given input (booknum), check input, , feed valid input new array (book). @ line
'booknum.charat[j]==book[i]'
i 'not statement error'. gives?
string[] book = new string [isbn_num]; booknum.replaceall("-",""); if (booknum.length()!=isbn_num) throw new isbnexception ("isbn "+ booknum + " must 10 characters"); (int i=0;i<booknum.length();i++) { if (character.isdigit(booknum.charat(i))) booknum.charat[j]==book[i]; j++; if (book[9].isnotdigit()|| book[9]!="x" || book[9]!="x") throw new isbnexception ("isbn " + booknum + " must contain digits" + "or 'x' in last position");
there few odd problems here. starters, did mean book array of strings, opposed 1 string? you're trying (assuming charat written , assignment proper) assign character string.
second, instead of copying character character, why not check whole string, , copy whole thing @ end if proper isbn? depending on exceptions (if continue regardless), add boolean flag gets set if there error. @ end, if there no error, make book = booknumber.replace(etc...)
Comments
Post a Comment