Write a Java program to accept a set of numbers. Check and print whether each number is even or odd. The program terminates when 0(ZERO) is entered from the console
Answers
Answered by
6
Answer:
import java.util.*;
public class Even_Odd
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int n=1;
while(n!=0))
{
System.out.println("Enter a number and 0 to end:");
n=in.nextInt();
if(n==0)
break;
if(n%2==0)
System.out.println(n+"is an even number");
else
System.out.println(n+"is an odd number");
}
}
}
Similar questions
Math,
5 months ago
Math,
5 months ago
English,
5 months ago
English,
10 months ago
Math,
10 months ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago