Guest User

Untitled

a guest
Sep 29th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public class Toenglish{
  2. public static void main(String[] args){
  3. int x = Integer.parseInt(args[0]);
  4. int d = (args[0]).length();
  5. String Units,Tens,Hundreth,Thousand,TenThousand, HundredThousand;
  6. Units = " ";
  7. Tens = " ";
  8. Hundreth = " ";
  9. Thousand = " ";
  10. TenThousand = " ";
  11. HundredThousand = " ";
  12. String full = "";
  13. String[] units = {
  14. "",
  15. " one",
  16. " two",
  17. " three",
  18. " four",
  19. " five",
  20. " six",
  21. " seven",
  22. " eight",
  23. " nine",
  24. " ten",
  25. " eleven",
  26. " twelve",
  27. " thirteen",
  28. " fourteen",
  29. " fifteen",
  30. " sixteen",
  31. " seventeen",
  32. " eighteen",
  33. " nineteen"
  34. };
  35. String[] tensNames = {
  36. "",
  37. " ten",
  38. " twenty",
  39. " thirty",
  40. " forty",
  41. " fifty",
  42. " sixty",
  43. " seventy",
  44. " eighty",
  45. " ninety"
  46. };
  47. while(x>=0){
  48. if(x%100>0 && x%100<20){ // 0-20
  49. Units += units[x%100];
  50. System.out.print(units[x%20]);
  51. x/=100;}
  52. else{
  53. Tens += tensNames[(x%100)/10];
  54. x = x%10;}
  55. if(x/100<10){
  56. Hundreth += units[x/100] + " Hundred";
  57. x = x%100;}
  58. if(x/1000>0 && x/1000<20){
  59. Thousand += units[x/1000] + " Thousand";
  60. x = x%1000;}
  61. if(x/10000>20 && x/10000<100){
  62. TenThousand += tensNames[x/10000];
  63. x = x%10000;}
  64. if(x/100000<10){
  65. HundredThousand += units[x/100000]+ " Hundred";
  66. x = x%100000;}
  67.  
  68.  
  69.  
  70. }
  71. System.out.println(HundredThousand + TenThousand + Thousand + Hundreth + Tens + Units);
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. }
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. }
Add Comment
Please, Sign In to add comment