Program to print the given digit in words | Java implementation of the above approach ; Function to return the word of the corresponding digit ; Switch block to check for each digit c ; For digit 0 ; For digit 1 ; For digit 2 ; For digit 3 ; For digit 4 ; For digit 5 ; For digit 6 ; For digit 7 ; For digit 8 ; For digit 9 ; Function to iterate through every digit in the given number ; Finding each digit of the number ; Print the digit in words ; Driver code
class GFG { static void printValue ( char digit ) { switch ( digit ) { case '0' : System . out . print ( " Zero ▁ " ) ; break ; case '1' : System . out . print ( " One ▁ " ) ; break ; case '2' : System . out . print ( " Two ▁ " ) ; break ; case '3' : System . out . print ( " Three ▁ " ) ; break ; case '4' : System . out . print ( " Four ▁ " ) ; break ; case '5' : System . out . print ( " Five ▁ " ) ; break ; case '6' : System . out . print ( " Six ▁ " ) ; break ; case '7' : System . out . print ( " Seven ▁ " ) ; break ; case '8' : System . out . print ( " Eight ▁ " ) ; break ; case '9' : System . out . print ( " Nine ▁ " ) ; break ; } } static void printWord ( String N ) { int i , length = N . length ( ) ; for ( i = 0 ; i < length ; i ++ ) { printValue ( N . charAt ( i ) ) ; } } public static void main ( String [ ] args ) { String N = "123" ; printWord ( N ) ; } }