I have used reader.read(int) as this is the only way I can get it to read each digit not the whole line and give the correct odd and even count.
I can't get String.length() to work at all either.
Any tips would be appreciated 😁
package com.codegym.task.task06.task0606;
import java.io.*;
/*
Even and odd digits
*/
public class Solution {
public static int even;
public static int odd;
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for ( int i = 0; i < 5; i++ ){
int n = reader.read();
if ( n % 2 == 0 || n == 0 ){
even++;
} else if ( n % 2 != 0 ){
odd++;
} else {
}
}
System.out.println("Even: "+even+" Odd: "+odd+"");
///////////////////
}
}