The goal of this assignment for my cs class is to search a string for digits and change them to the written form 

ex: `4 -> four`

It's a relatively simple task. I have two problems however:

1) due to my current code if I convert a string of just **"8"** and try and make it **"eight"**, it won't work because it's longer than the current length of the string. 

2) dealing with more than one number char in a row through the string. I have it somewhat figured out. If you run what I have with certain `Strings` it works. We're supposed to separate more than one number char with a hyphen.

Here is my code:

```
public class NumberConversion {

    /**
     * * Class Constants **
     */
    /**
     * * Class Variables **
     */

    /* No class variables are needed due to the applet not having a state.
     All it does is simply convert. */
    /**
     * * Class Arrays **
     */
    char numberChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    String numbers[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};

    /**
     * * Accessor Methods **
     */
    /**
     * * Transformer/Mutator Methods **
     */
    public void writeNumber(String phrase) {
        /**
         * Local Variables *
         */
        String newPhrase = "";
        int j = 0;
        int k = 0;

        phrase = phrase.trim();

        /**
         * * Counts through the length of phrase **
         */
        for (int i = 0; i < phrase.length(); i++) {
            /**
             * * If the current char is a number char, enter the next repitition
             * structure **
             */
            int l = i + 1;

            if (isNumber(phrase.charAt(i)) && isNumber(phrase.charAt(i + 1))) {
                boolean searchArray = true;

                do {
                    if (numberChar[ j] == phrase.charAt(i)) {
                        searchArray = false;
                    }

                    j++;

                } while (searchArray && j < numberChar.length);

                phrase = phrase.replace(Character.toString(phrase.charAt(i)), numbers[ j - 1] + "-"); //error HERE

            }

            if (isNumber(phrase.charAt(i))) {
                boolean searchArray = true;

                do {
                    /**
                     * * Counts through numberChar array to see which char was
                     * found in the phrase. Stops when found **
                     */
                    if (numberChar[ k] == phrase.charAt(i)) {
                        searchArray = false;
                    }

                    k++;

                } while (searchArray && k <= numberChar.length);

                /**
                 * * Changes char to string and replaces it with the matching
                 * String numbers array element **
                 */
                phrase = phrase.replace(Character.toString(phrase.charAt(i)), numbers[ k - 1]);
            }
            phrase = phrase.replace("- ", " ");
        }
        System.out.println(phrase); // Prints the changed phrase.
    }

    /**
     * * Helper Methods **
     */
    /**
     * * Observer Methods **
     */
    public boolean isNumber(char input) {
        boolean isNumber = false; // Initially fails

        for (int i = 0; i < numberChar.length; i++) {
            /**
             * * If input matches a number char, method returns true **
             */
            if (input == numberChar[ i]) {
                isNumber = true;
            }
        }
        return isNumber;
    }
}

```