# Application that determines and prints odd, even and zero digit in an integer value

• February 3rd, 2009, 03:04 AM
Konnor
Application that determines and prints odd, even and zero digit in an integer value
howdy,

Another problem I've hit a wall with.

The problem is to implement an application that determines and prints the number of odd, even, and zero digits in an integer value read from the keyboard.

I can't think how to split the int up to check the individual values.

Any tips?

(I'm still new to this and haven't gone onto arrays yet, so if possible could a solution be found that is still quite basic)

Many thanks,
• February 4th, 2009, 05:31 AM
JavaPF
Re: checking individual digits of an int
Hello Konnor,

You can split the given int into individual values by using the java Split function.

I will write you a quick example ASAP but for now I suggest you check Google so you can get familiar with it.
• February 4th, 2009, 11:24 AM
JavaPF
Re: checking individual digits of an int
Because the Split function needs a delimiter, and your int value wont contain one suitable I have had to use another method to split the intager after each number.

Take a look at this code. The given int value is split after each number and put into an Array which you can then work with..

Code :

```import java.util.Scanner;   public class Konnor2 {   public static String stringInt;   public static void main(String[] args) {   System.out.println("Enter Integer Value: "); Scanner sc = new Scanner(System.in); stringInt = sc.next();   String splitInt[] = new String[stringInt.length() / 1];   for(int a = 0; a < splitInt.length; a++){ splitInt[a] = stringInt.substring(a * 1, a * 1 + 1); System.out.println(splitInt[a]); } }   }```
Let me know if you need help with coding the rest...