Results 1 to 2 of 2
  1. #1
    Wizard0860 is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default 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. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power

    Default 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)

Similar Threads

  1. Replies: 1
    Last Post: 07-27-2012, 09:24 AM
  2. Help with printing simple things.
    By Aimforthehead in forum New To Java
    Replies: 4
    Last Post: 12-02-2011, 02:01 AM
  3. Need Help. with two simple things
    By Fred1 in forum New To Java
    Replies: 32
    Last Post: 04-28-2011, 02:35 AM
  4. things necessary to take note of before going to learn EE
    By kulangotski in forum New To Java
    Replies: 0
    Last Post: 12-28-2010, 07:30 AM
  5. XML, and other things.
    By Tortex in forum New To Java
    Replies: 5
    Last Post: 03-28-2010, 05:53 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