1 Write a program that inputs integers from the keyboard (no limit to the entries; end by entering 0), and lists the even numbers and then lists the odd numbers.
int odd =0;
int even =0;
while (entry !=0)
System.out.println("Enter 0 to exit the program.");
entry = MyInput.readInt();
i know how to get the numbers nut not how sepperated the numbers odd from even
i assume you mean that the program must display the number of odd and the number of even integers entered?
to check if a number is even or odd you can use the % operator:
if( ( myNumber % 2 ) == 0 )
//the number is even so add 1 to your even counter
//the number is odd so add 1 to your odd counter
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL