Hey, there.
When I run this program, everything seems to work and I obtain the correct result. But when I try to verify, it says that the 2nd and 3rd requirements are not fulfilled.
"Be sure that the number of even digits is stored in the variable even."
and
"Be sure that the number odd digits is stored in the variable odd."
I can't find what I did wrong.
Could someone help me?
Thanks!
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));
String s = reader.readLine();
int number = Integer.parseInt(s);
int even = 0;
int odd = 0;
while(number != 0) {
if(number % 2 == 0) {
even = even + 1;
}
else {
odd = odd + 1;
}
number = number / 10;
}
System.out.println("Even: " + even + " Odd: " + odd);
}
}