Simple Question

Is there a way to check if an integer is even or odd?I'm a new Java student this, my freshman, semester and am working on a "homework" assignment the TA gave me since I was working on stuff on my own.
[215 byte] By [tuptaina] at [2007-10-3 3:54:33]
# 1
If I gave you a number and asked you whether it was even or odd how would you do it?
cotton.ma at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 2
Obviously, if I could divide it by two evenly. So I guess my next question would be, how do I tell if the number that results is an int or a double.
tuptaina at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 3
google % (modulous) and see what that brings up for you.
Aknibbsa at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 4
> Obviously, if I could divide it by two evenly. So I> guess my next question would be, how do I tell if the> number that results is an int or a double.?Int divided by an int will give you an int.
Aknibbsa at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 5
wait...
tuptaina at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 6

> Obviously, if I could divide it by two evenly. So I

> guess my next question would be, how do I tell if the

> number that results is an int or a double.

Luckily integer division produces integers. As the other poster said look up modulus and in two shakes of a lambs tail you're done.

cotton.ma at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 7
:D Remainders are my friend.
tuptaina at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...
# 8
not like that evil quotient A bitter sworn enemy to all that are good :-)
Aknibbsa at 2007-7-14 21:52:32 > top of Java-index,Java Essentials,Java Programming...