Like David, I was thinking of ceiling but it looks like you're going with the
10s complement which will work, too.
There's different way to look at "rem >= 1 && rem < 10" in this case that will simplify the conditional expression a little bit. If your only choices are 0, 1, 2, ..., 9 then how would you write the condition so you don't have to use the "&&" operator? Hint: If it's a number from 1 to 9, then it's
not what?.
The ceiling method would look at it this way: Given X
where X is not a multiple of 10, what is the smallest multiple of 10 that is greater than X? Solution: Add 10 to X, then round down to the nearest 10.
Of course now you have to figure out how to round down. Rounding down is more straightforward though considering that in
Java, integer division ignores the remainder. That is,
int x = 11 / 10; // x == 1
int x = 19 / 10; // x == 1
[ January 29, 2005: Message edited by: Junilu Lacar ]