# Thread: Need help with GUI and integers(just some basic things)

1. Member
Join Date
Nov 2012
Posts
29
Rep Power
0

## Need help with GUI and integers(just some basic things)

Hi so im sorta new to Java, and in one of my programs, i am doing the Hailstone numbers algorithm, and if you don't know, they work like this: if a number is odd, multiply it by 3 and add one, and if it is even, divide by two, and keep doing this til u get 1. So my question is, i am using an if statement, which will work when i get the value of x(my int) from the label. my statement is: if(x==even) but it doesn't work because even is not a method. so what can i do to make it so that if x is even, then do blah blah blah (i know how to code the rest).

2. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
14

## Re: Need help with GUI and integers(just some basic things)

Check out the % (remainder) operator. 42%10 is 2, 666%37 is 0, etc. Because 666%37==0 is true we can conclude that 37 is a factor of 666.

Assignment, Arithmetic, and Unary Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

#### Posting Permissions

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