Suppose you have an int variable called number. what java expression produces the second-to-last digit of the number (the 10s place)? what expression produces the third-to-last digit of the number (the 100s place)?

Respuesta :

private int number = 123;
// using this number "123"

int hundred = (number % 10); // gets third to last
number /= 10;
int tenth = (number % 10); // gets second to last
number/=10;
int ones = (number % 10); // first digit