I am doing an assignment for class I basicly have to read a interger value from the keyboard in by the user. Then disect it find out how many odds,evens, and zeros are in it.
So if they enter in 250 then that is 1 even, 1 odd, 1 zero.
I written the input part, and the if statement to
test what it would be. My problem is that I am not sure how to break it up so that it reads each number in seperatley.
Since if the user enters 20 in or something like that how I have it now it will just say this is just 1 even number. So my program can do figure it 100% from 0-9 but after that it just reads it as one big digit.
So I am wondering if there is away to break a int up to each character. Like I know if this was a
String I could just use the length()-1 method with CharAt() with a loop and use a while loop to go through one by one and this while loop would have all my if statements in it.
But I am not sure if something exists for that for a int value. I would use a String but then it would allow people to put in words and that that would screw up my whole program unless I wrote something that would not allow this. Also how the question is worded it wants me to take a integer value in so if I do the String way I won't be doing this so I don't even think I would be allowed to do this.
[ February 18, 2006: Message edited by: Michael Hubele ]
[ February 18, 2006: Message edited by: Michael Hubele ]
[ February 18, 2006: Message edited by: Michael Hubele ]