title: How do I convert a check to words that includes the decimal position as well
body: <p>I have been given an assignment to write a method that takes a monetary value less than $1000.00 and writes the word equivalent of that amount.  This amount needs to include the part after the decimal as well (essentially the change part of the amount).<br>
  i.e.</p>
  
  <pre><code>Enter·check·amount:567.89↵
  five·hundred·sixty·seven·and·89/100↵
  </code></pre>
  
  <p>I see that the topic has been covered numerous times but I can't seem to find any information on what I'm requesting. I am new to this (4 weeks) so forgive me if I'm asking the wrong questions or stating what I've done in the wrong manner.  I'm able to output the amount in words (as you can see from my result) but I believe the issue I am having lies somewhere in the user entering a Double and my code not including anything requesting &lt;1000.00.  My main method does include the double number but each time I try to change the Int type in the moneyWord method to a Double the number Int in my If statements states that an int cannot be converted to a Double(which I know).  Also, I think my return statement may needs to include more information.  Again, I may be looking in the wrong direction for the error but I believe this is where I'm going wrong.  In addition, I think some of this material may be taught in future classes as I had to look into chapters in my textbook that have not yet been covered - namely Arrays.  Here is my code.  Any assistance would be appreciated</p>
  
  <pre><code>//program to write the word equivalent of a check amount
  import java.util.Scanner;
  
  public class CheckToWord {
      public static void main(String[] args) { // main method
          double number = 0;
          Scanner scanner = new Scanner(System.in);
          System.out.println("Please enter the check amount:"); // prompt user to enter check amount
          number = scanner.nextDouble();
  
          if (number == 0) {
              System.out.print("Zero");
          } else {
              System.out.print("" + moneyWord((int) number)); // output amount in words
          }
      }
  
      private static String moneyWord(int number) {
          String words = ""; // variable to hold string representation of number
          String onesArray[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                  "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
          String tensArray[] = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty",
                  "ninety" };
  
          if (number &lt; 0) { // convert the number to a string
              String numberStr = "" + number;
              numberStr = numberStr.substring(1); // remove minus before the number
              return "minus " + moneyWord((int) Double.parseDouble(numberStr)); // add minus before the number and convert
                                                                                  // the rest of number
          }
  
          if ((number / 1000) &gt; 0) { // check if number is divisible by 1 thousand
              words += moneyWord(number / 1000) + " thousand ";
              number %= 1000;
          }
  
          if ((number / 100) &gt; 0) { // check if number is divisible by a hundred
              words += moneyWord(number / 100) + " hundred ";
              number %= 100;
          }
  
          if (number &lt; 20) { // check if number is within the teens
              words += onesArray[number]; // get the appropriate value from ones array
          } else {
              words += tensArray[number / 10]; // get the appropriate value from tens array
              if ((number % 10) &gt; 0) {
                  words += "-" + onesArray[number % 10];
              }
          }
          return words;
      }
  }
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>Please enter the check amount:
  1523.23
  one thousand five hundred twenty-three
  </code></pre>