Results 1 to 7 of 7
Thread: if if else help plase
- 10-16-2012, 02:36 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 8
- Rep Power
- 0
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
- 10-16-2012, 02:44 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
Re: if if else help plase
}else if (noofstays >5 && noofstays<9){//nb say ;expected
- 10-16-2012, 02:50 PM #3
Member
- Join Date
- Sep 2012
- Posts
- 8
- Rep Power
- 0
- 10-16-2012, 02:58 PM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 294
- Rep Power
- 0
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.
- 10-16-2012, 03:01 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,467
- Rep Power
- 16
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.
- 10-16-2012, 03:02 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,467
- Rep Power
- 16
Re: if if else help plase
Ah.
Oh well, I never read unformatted code...:)Please do not ask for code as refusal often offends.
- 10-16-2012, 03:13 PM #7
Member
- Join Date
- Sep 2012
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Help Plase
By Aggy in forum New To JavaReplies: 3Last Post: 04-25-2012, 04:37 PM -
plase help me
By nassir in forum JCreatorReplies: 38Last Post: 12-24-2009, 07:38 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks