aspose file tools*
The moose likes Beginning Java and the fly likes if statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "if statements" Watch "if statements" New topic
Author

if statements

Bob Holland
Greenhorn

Joined: Dec 15, 2004
Posts: 7
hi there all, im trying to write a program something like this



if "percentage"(this is a variable) is between 30 and 40 then print .............

but i dont know the syntax for the between bit, i can do greater than, less than, and equal, but not between, please help me!!!
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
if ( i >= 30 && i <= 40 ) { }


Mike Gershman
SCJP 1.4, SCWCD in process
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4679
    
    7

"between 30 and 40"

can be restated as

"greater than 30 and less than 40" (excluding 30 & 40)

or

"greater or equal to 30 and less than or equal to 40" (inclusive)

the logical "and" operator normally used in Java is &&


Junilu - [How to Ask Questions] [How to Answer Questions]
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
Bob Holland
Greenhorn

Joined: Dec 15, 2004
Posts: 7
wow, thanx a lot, i was stumped for ages, thanx again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if statements