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)?
(Note: Our code checker won't match every possible expression; please come up with the simplest expression using division and modulus.)
10s place
100s place

Respuesta :

Debel

Answer:

int second_to_last = (number/10)%10;

int third_to_last = (number/100)%10;

Explanation:

The first expression int second_to_last = (number/10)%10; first divide the number by ten and then get modulus by dividing by ten again which will then give the second to last digit.

Assuming number is 146 the second to last digit will be 4.

for the second expression int third_to_last = (number/100)%10; first divide the number by hundred and then get modulus by dividing by ten which will then give the third to last digit.

Assuming number is 4368 the third to last digit will be 3.

ACCESS MORE
EDU ACCESS