Computer Science, asked by esha1515pal, 10 months ago

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 shivu0518
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