I need to design an application that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard. This is what I have so far.
public static void main (String[] args)
{
int odd=0, even=0, zero=0;
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
String numS = Integer.toString(num);
int digits = numS.length();
for (int i = 0; i < digits; i++)
{
if (numS.indexOf(i) == 0)
{
zero++;
}
else if (numS.indexOf(i) % 2 == 0)
{
even++;
}
else
{
odd++;
}
}
System.out.println("The number of odd digits are: " + odd);
System.out.println("The number of even digits are: " + even);
System.out.println("The number of zero digits are: " + zero);
}