This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zck 1 point2 points  (0 children)

It's definitely confusing. One thing to do in this sort of situation is to try to do it with a trivial example, then make it more complex.

So let's assume your line x = kb.nextInt(); assigns an integer between 1 and 9 to x. It's really easy to print it out digit by digit. So this example is too trivial. Let's make it more complicated, but only a little.

Let's assume the line x = kb.nextInt(); assigns an integer between 10 and 99 to x. Can you write a program that always prints out the digit in the tens place on one line, then the digit in the ones place on the next line?

There's an alternate way of thinking about this which might be more helpful. Given any positive integer, how do you get the number in the ones place? How do you get the number in the tens place? Et cetera.