Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Even/Odd program in Java

$
0
0
I have a piece of code which is supposed to determine whether or not a number is even or odd.
public class CS1702_Lab8 {
	public static void main(String args[])
	{
		int i;
		boolean eo;
		String s = "";
		
		for(i=1;i<=25;++i)
		{
			eo = EvenOdd(i);
			s = (eo)?"Even":"Odd";
			System.out.println(i + " is " + s);
		}
	}
	public static boolean EvenOdd(int x)
	{
		return false;
			
		
	}
	

}



If I add return false it prints out that all the numbers between 1 and 25 odd.
What should I change?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>