I have tried various inputs and got the corresponding results. Not satisfying requirements 2, 3 and 5 each time.
The while loop is used to find the number of digits.
n/(int)Math.pow(10,j) extracts each digit.
Hints on other ways would be helpful.
package com.codegym.task.task06.task0606;
import java.io.*;
import java.lang.Math;
/*
Even and odd digits
*/
public class Solution {
public static int even;
public static int odd;
public static void main(String[] args) throws IOException {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(read.readLine());
int i = 1, temp = n;
while(temp>0) {
temp = temp/(int)Math.pow(10,i);
i++;
}
i--;
for(int j=i; j>=0; j--){
if((n/(int)Math.pow(10,j))%2==0){
even++;
n = n%(int)Math.pow(10,j);
}
else {
odd++;
n = n%(int)Math.pow(10,j);
}
}
System.out.println("Even: "+even+" Odd: "+odd);
}
}