I know this is probably seem to be very easy for you guys. I have been trying to figure this out for three hours. The requirement ask me to write a method determine whether an integer is even or not. If it is true, return true. If it is false, return false.
here is my code, I think I did it right.
public class IsEven
{
public boolean evenNumber( int x)
{
int even = x;
if ( even%2 == 0)
return true;
else
return false;
}
}
Then incorporate the method into an application that inputs some random integer numbers(a sequence of number) and determines whether it is odd or even. So I know I need to use method call here and generate the random by using java.util. But for some reason I stuck on method call and pass random numbers I general to the method I wrote.
here is the code I wrote so far.
import java.util.Random;
public class DetermineEven
{
public static void main(String[] args)
{
Random randomNumber = new Random();
IsEven evenNumber = new IsEven();
for (int counter=0; counter<20; counter++)
{
int x = 1+ randomNumber.nextInt(10);
IsEven.evenNumber();
System.out.println(even);
}
}
}
Thank you so much.