Created
December 26, 2016 19:30
-
-
Save rawsh/35a77d5238bd5a2974110ba4618d8be5 to your computer and use it in GitHub Desktop.
Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ones = t % 10; | |
int twos = (t-t%10)/10; | |
String[] singledigits = new String[] {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; | |
String[] doubledigits = new String[] {"", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"}; | |
String[] teens = new String[] {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"}; | |
if (twos == 0) { | |
inwords = singledigits[ones]; | |
} else if (twos == 1) { | |
inwords = teens[ones]; | |
} else { | |
if (ones != 0) { | |
inwords = doubledigits[twos] + " " + singledigits[ones]; | |
} else { | |
inwords = doubledigits[twos]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment