Menu

Display no. of even digits and odd digits of a number- Java Program

import java.util.*;
class Display_count_of_even_odd_digits{
public static void main(String args[]){

System.out.println("Enter a number");
Scanner sc = new Scanner(System.in);
int number= sc.nextInt();
int count_even=0;
int count_odd=0;

while(number!=0)
{
int digit= number%10;
if(digit%2==0)       count_even++;
else                         count_odd++;
number=number/10;
}

System.out.println("The no of even digits in the given number are  " +count_even);
System.out.println("The no of odd digits in the given number are  " +count_odd);


}}