To construct an algorithm, best way is write it down on a paper first; that is, do it by hand before trying to make a computer do it.
A pseudo-code for your task could be
while n is greater than zero
if n is odd, return 0
divide n by 10
return 1
You do not need to count the number of even numbers. Neither do you need all these global variables.
Now try to translate that pseudo code to java, using your course and asking your teacher if there is something you do not understand.