{ Scanner sc = new Scanner(System.in); System.out.println("Enter the number"); int n = sc.nextInt(); String num = String.valueOf(n); //Converting int to string type; for(int i=0 ; i<num.length() ; i++) { switch(num.charAt(i)) { //checking the alphanumeric value for the 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; } } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter