Hardik Sirvi Hardik Sirvi - 20 days ago 4x
Java Question

About a Looping Program in Java

I need a Program in Java in which I can give any number to the program and in return it tells me that how many odd or even digits are present in that number.
for Example:- I give - 1234567,then it tells me that Even-3 digits and Odd - 5 digits Thank You

public class Count
  public void display(int number)
   int a,nOdd =0 ,nEven=0;
   while(number > 0)
     a = number % 10;
     nEven ++;
     nOdd ++;
     number = number / 10;
  System.out.println("No. of Odd digits = "+nOdd);
  System.out.println("No. of Even digits = "+nEven);