Created
August 10, 2012 00:05
-
-
Save JossWhittle/3309323 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public void p17() { | |
long v = 0L; | |
for (int i = 1; i 0) { | |
int digit = (int)Character.digit(a.charAt(0), 10); | |
if (digit == 0) { | |
return "and" + toword(a.substring(1)); | |
} | |
String ad = ""; | |
if (Integer.parseInt(a.substring(1)) > 0) { | |
ad = "and"; | |
} | |
return low[digit] + "hundred" + ad + toword(a.substring(1)); | |
} | |
} else if (a.length() == 2) { | |
if (Integer.parseInt(a) > 19) { | |
int digit = (int)Character.digit(a.charAt(0), 10); | |
if (digit == 0) { | |
return "and" + toword(a.substring(1)); | |
} | |
return tens[digit - 1] + toword(a.substring(1)); | |
} else if (Integer.parseInt(a) > 0) { | |
return low[Integer.parseInt(a)]; | |
} | |
} else if (a.length() == 1) { | |
int digit = (int)Character.digit(a.charAt(0), 10); | |
if (digit != 0) { | |
return low[digit]; | |
} | |
} | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment