title: Project Euler number to word problem
body: <p>I have tried to develop code for project euler 
  <a href="http://projecteuler.net/index.php?section=problems&amp;id=17" rel="nofollow">Problem 17</a></p>
  
  <p>I have successfully written a java program and the output appears as expected. But however the online judge says it is the wrong answer. Have a look at my code:</p>
  
  <pre><code>package projectEuler;
  
  import java.util.*;
  public class Problem17 {
  
  /**
   * @param args
   */
  static String []units={"","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
  
  static String []special={"Ten","Eleven","Twelve","Thirteen","Fourteen",
                      "Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
  
  static String []tens={"","","Twenty","Thirty","Forty","Fifty","Sixty","Seventy",
                  "Eighty","Ninety"};
  
  static String hundredValue="Hundred and";
  
  public static void main(String[] args) 
  {    
   long totalLength=0;
   for(int currentNumber=1;currentNumber&lt;=1000;currentNumber++)
   {
       String currentWord=getWords(currentNumber);
      // System.out.println(currentNumber+"-&gt;"+currentWord.replaceAll(" ",""));
       totalLength+=currentWord.replaceAll(" ","").length();
  
   }
   System.out.print("The total length of all the word is :"+totalLength);
   /*Scanner input = new Scanner(System.in);
   System.out.print("Enter a number :");
   int num = input.nextInt();
   System.out.print(getWords(num));*/
  }
  
  public static String getWords(int num) 
  {      
      //Find the equivalent word and return it
  
      String wordValue="";
  
      switch(String.valueOf(num).length())
      { 
       case 1:
         wordValue=operateOn_1(num);   
       break;
  
       case 2:
        wordValue= operateOn_2(num);
       break;
  
       case 3:
        wordValue= operateOn_3(num);
       break;
  
       default:
        wordValue="One Thousand";  
      }
      return wordValue;
  }
  
  public static String operateOn_3(int num) 
  {
  
    String result="";
    result= Problem17.units[num/100]+" "+
            Problem17.hundredValue+" "+
           operateOn_2(Integer.parseInt((String.valueOf(num).substring(1))));
    return result;
  }
  
  public static String operateOn_2(int num) 
  {
      String result="";
     if(String.valueOf(num).charAt(0)=='1')
     {
       result=Problem17.special[num%10];
     }
     else
     {           
         result=Problem17.tens[Integer.parseInt(String.valueOf((String.valueOf(num)).charAt(0)))];
         result+=" "+operateOn_1(num%10);
     }
      return result;
  }
  
  public static String operateOn_1(int num) 
  {
  
      return (Problem17.units[num]);
  }
  
  }
  </code></pre>
  
  <p>The total length which the program found out as <code>21592</code> but it is wrong according to project euler. If any could have a look at my code and help me please...</p>