check whether s [ i ] is a character or a integer between 0 to 9 and compute its equivalent BCD
if ( s . charAt ( i ) >= 47 && s . charAt ( i ) <= 52 ) { String result = Integer . toBinaryString ( ( int ) s . charAt ( i ) ) ; System . out . print ( result . substring ( result . length ( ) - 4 ) + " ▁ " ) ; } else { String result = Integer . toBinaryString ( ( int ) s . charAt ( i ) - 55 ) ; System . out . print ( result . substring ( result . length ( ) - 4 ) + " ▁ " ) ; } } }