简体   繁体   中英

how do i change last digits 0 to 1 in java?

I am supposed to make an if statement program that changes the last digit to 1 if it ends in 0 .

input is a whole number.

Example:

12340 changed to 12341
1230320 changed to 1230321

You should check for last digit and if it is zero then add 1 to number.

if(number%10 == 0)
{ 
   return number +1;
}
return number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM