Displaying even numbers
Hey guys, this is my first time on here and I hope you can help :)
My problem is that I need to make the following peice of code display only even numbers, does anyone have any idea how?
Thank you.
//Akash Thakkar
import java.io.*;
class NewLoop
{
public static void main (String[] args) throws IOException
{
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
String inputData;
int count, limit;
System.out.println ("Enter an integer:"); //User inputs starting value
inputData = stdin.readLine();
count = Integer.parseInt (inputData);
System.out.println ("Enter another integer:"); //User imputs limit
inputData = stdin.readLine();
limit = Integer.parseInt (inputData);
for (count = count; count > limit; count--) //If the count is bigger than the limit, count downwards in decrements of 1
{
System.out.println (count + " ");
}
for (count = count; count <= limit; count++) // If the count is smaller than or equal to the limit, count upwards in increments of 1
{
System.out.println (count + " ");
}
for (count = count; count == limit; count = count) //If the count is equal to the limit, don't count up or down
{
System.out.println (count + " ");
}
}
}

