Results 1 to 7 of 7
  1. #1
    rockstaedy is offline Member
    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0

    Default if if else help plase

    hi i am trying to use a if if else statement to decide what class is used but netbeans is telling me my syntax is
    wrong im pritty sure it aint any help would be great
    class names=GoldCustomer,PlatinumCustomer,HighFlyer,Norm Customer


    if(noofstays<5){
    GoldCustomer object = new GoldCustomer(duration,roomtype,noofstays,gymusage) ;
    System.out.println(object);
    }else if (noofstays >5 && <9){//nb say ;expected

    PlatinumCustomer object1 = new PlatinumCustomer(duration,roomtype,noofstays,gymus age);

    }else if(noofstays >9){//else without if
    HighFlyer object2 = new HighFlyer(duration,roomtype,noofstays,gymusage); //all variables underlined?

    }else {//illegal start of type
    NormCustomer object3 =new NormCustomer();
    }


    i know my user name is spelt wrong

  2. #2
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default Re: if if else help plase

    }else if (noofstays >5 && noofstays<9){//nb say ;expected

  3. #3
    rockstaedy is offline Member
    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0

    Default Re: if if else help plase

    Quote Originally Posted by Addez View Post
    }else if (noofstays >5 && noofstays<9){//nb say ;expected
    yes but ;doesint belong here i have done other if statements to try it out and make sure im not crazy the syntax seem right
    this is a pain

    i have allso tryed puting ; at end inside and outside brackets--no work

  4. #4
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default Re: if if else help plase

    }else if (noofstays >5 && noofstays<9){
    this is the solution.
    You wrote:
    }else if (noofstays >5 && <9){
    You should have written:
    }else if (noofstays >5 && noofstays<9){

    Thats the solution.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: if if else help plase

    Can you supply the whole method?
    And make sure it is in [code] tags [/code].
    That sort of error is almost always down to a misplaced bracket, or ;, so make sure your code is formatted correctly (Netbeans can do this for you).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: if if else help plase

    Ah.
    Oh well, I never read unformatted code...:)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    rockstaedy is offline Member
    Join Date
    Sep 2012
    Posts
    8
    Rep Power
    0

    Default Re: if if else help plase

    thanks
    }else if (noofstays >5 && noofstays<9){
    that did it

Similar Threads

  1. Help Plase
    By Aggy in forum New To Java
    Replies: 3
    Last Post: 04-25-2012, 04:37 PM
  2. plase help me
    By nassir in forum JCreator
    Replies: 38
    Last Post: 12-24-2009, 07:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •