Replace all â €˜ 0 â €™ with â €˜ 5 â €™ in an input Integer |  ; returns the number to be added to the input to replace all zeroes with five ; amount to be added ; unit decimal place ; a number divisible by 10 , then this is a zero occurrence in the input ; move one decimal place
public class ReplaceDigits { static int replace0with5 ( int number ) { return number += calculateAddedValue ( number ) ; } private static int calculateAddedValue ( int number ) { int result = 0 ; int decimalPlace = 1 ; if ( number == 0 ) { result += ( 5 * decimalPlace ) ; } while ( number > 0 ) { if ( number % 10 == 0 ) result += ( 5 * decimalPlace ) ; number /= 10 ; decimalPlace *= 10 ; } return result ; } public static void main ( String [ ] args ) { System . out . print ( replace0with5 ( 1020 ) ) ; } }