Recieving Illegal start of expression error in Java -


just hoping bit of guidance on code. first bit (see below), trying make instance method pretty add given values. issue keep getting illegal start of expression error. wondering if able explain why, since looks fine me? keep in mind posted portion of code receiving error message.

edit wanted open question second since whatever reason recieving odd error. able code completed receiving error message when test stating illegalargumentexception: letter chosen invalid. must t, d, or e. given data 84 ignored. i'm wondering why error message appearing since choosing on of letters , i'm not using 84 number @ all.

public int addnewvalue ( char amttype, int amount) {     scanner keyboard= new scanner (system.in);     system.out.println("please enter amount in dollars");     amount=keyboard.nextint();         system.out.println("please select amount type: t-ticket sales,"             + " d-donations, e-expenses");     amttype=keyboard.next().charat(0);     if (amount<=0) {        throw new illegalargumentexception("amount must positive , "                + "non-zero. given data " +amount+ " ignored.");  //below recieve error message     }else if (amttype !=t&&!=d&&!=e ) {            throw new illegalargumentexception ("the letter chosen invalid."                    + "must t, d, or e. given data " +amttype+                     " ignored");         }else{        return amount + amttype;    }  } 

try write if condition this:

    }else if (amttype !='t' && amttype !='d' && amttype !='e' ) { 

with using && instead of || , use ' single quote check char.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -