Computer Science, asked by xxxse, 1 year ago

Write a program to accept a set of numbers. Check and print whether each number is even or odd. The program terminates when 0 is entered from the console.

Answers

Answered by Anonymous
4

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");

}

System.out.println("The program ends!!");

}

}

Similar questions