java - method declaration gives an error. What gives? -


so i'm still plugging away @ big assignment (thanks helping me figure out problem loop). have moved on start making checkdigit() method used validate whether check digit on isbn # valid (which have started screwing around with). here's problem: tried compile it, compiler tells me there expected @ method call. here snippet of beginner's code:

    private string validateisbn(string booknum)throws isbnexception {     boolean check=false;     booknum.replaceall("-","");     if (booknum.length()!=isbn_num)         throw new isbnexception ("isbn "+ booknum + " must 10 characters");     (int i=0;i<booknum.length()-1;i++)     {         if (character.isdigit(booknum.charat(i)))             check=true;     }       if (booknum.charat(9)=='x') check=true;     if (character.isdigit(booknum.charat(9))) check=true;     if (check=false) throw new isbnexception ("isbn " + booknum + " must contain digits" +                  "or 'x' in last position");     if (checkdigit()=false)             throw new isbnexception ("isbn " + booknum + " invalid.\n" +                  "isbn " + booknum + " should " + validnum);     if (check=true) return booknum; }                              public boolean checkdigit (booknum) {     double total=0.0;     char[] check   = {1,2,3,4,5,6,7,8,9,x};     int[] checknums= {1,2,3,4,5,6,7,8,9,10};     (int i=0;i<booknum.length;i++)         check(i)=booknum[i];         total+=check[i]*checknums[i];   

what mean? means missing curly brace somewhere, not case time.

edit

sorry obvious , stupid question. guys asked see actual compiler message, put top (buried), compiler

identifier expected

but put <> tags around identifier, took out word identifier, , says, "....but compiler tells me there expected @ method call, instead of, " ....but compiler tells me there identifier expected @ method call.

and enter @ start text field (which typing question) when pasted code, said 'enter code here', , didn't take out enter.

sorry

well appears in fact missing closing curly brace checkdigit method, plus stray enter doing before validateisbn method? also, need type booknum parameter checkdigit method, i.e., checkdigit(string booknum)

and lastly, you're attempting call checkdigit() without passing in arguments here:

if (checkdigit()=false)             throw new isbnexception ("isbn " + booknum + " invalid.\n" +                  "isbn " + booknum + " should " + validnum); 

you need provide booknum in method call.

furthermore, excellent idea post compiler message along question; someone's going ask it, it. plus, if take minute read compiler message, it's pretty obvious problem, @ least simple incorrect syntax.


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? -