I made some changes recently and it seems to be outputting the correct amount of even and odd digits in the correct spots, with the correct output text. But I'm still getting error messages from the validation.
EDIT: nvm, it seems that once I get up past 5 digit numbers it starts missing odd numbered digits.
package com.codegym.task.task06.task0606;
import java.io.*;
/*
Even and odd digits
*/
public class Solution {
public static int even = 0;
public static int odd = 0;
public static void main(String[] args) throws IOException {
//1. The program must read data from the keyboard.
//2. The main method should calculate how many even digits are in the entered number
// and then write this number to the variable even.
//3. The main method should calculate how many odd digits are in the entered number
// and then write this number to the variable odd.
//4. The program should display text on the screen.
//5. The displayed text must match the task conditions.
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
if (n <= 0){
n *= -1;
}
for (int i = 0; i <= n; i++) {
if (n % 2 == 0) {
even++;
n /= 10;
}
if (n % 2 != 0) {
odd++;
n /= 10;
}
}
System.out.println("Even:" + " " + even + " " + "Odd:" + " " + odd);
}
}