Recursion
A) Complete the public static Java method "power" below.  Your method must be
recursive and fully self-contained.  It should take two integer arguments, the
first being a base and the second being an exponent (the power to which the base
should be raised), and return the value produced when the base is raised to the
exponent.  For example, a call of power(4, 3) should return 64, whereas a call of
power(5, 1) should return 5.  A call of power(7, 0) should return 1.  You may not
use any FOR, WHILE, or DO-WHILE loops in your method; you must use recursion.
The method should not print anything.

    public static int power (int base, int exp)
    {
        // [Your Code Goes Here]
    }


B) Complete the public static Java method "reverseWordOrder" below.  Your method must
be recursive and fully self-contained.  It should take a single argument, a string,
reverse the order of the words in the string, and return the resulting string.  For
example, a call such as reverseWordOrder("Cats have lots of fur.") should return
"fur. of lots have Cats" (without the quotes).  You may not use any FOR, WHILE, or
DO-WHILE loops in your method; you must use recursion.  The method should not print
anything.

    public static String reverseWordOrder(String phrase)
    {
        // [Your Code Goes Here]
    }


C) Complete the public static Java method "stutter" below.  Your method must be
recursive and fully self-contained.  It should take a single argument, an integer,
replace every digit with two of that digit, and print the resulting value.  For
example, stutter(385) should print 338855, and stutter(-26) should print -2266.  A
call of stutter(0) should print 00, stutter(7) should print 77, and stutter(-409)
should print -440099.  You may not use any FOR, WHILE, or DO-WHILE loops in your
method; you must use recursion.  In addition, your method may not contain any
String variables or String methods.  The method should not return anything.

    public static void stutter(int num)
    {
        // [Your Code Goes Here]
    }


You should put all of the above methods into a single file named "Recursion.java".
You may find it helpful to create a 'main' method in that file from which you can
call and test your methods as you write them.


Advanced Option
Write a fully self-contained recursive public static Java method named "intermix"
that takes two arguments, both positive integers, intermixes the digits, and prints
the resulting value.  The intermixing should always start with the left-most digit
of the first argument, then move to the left-most digit of the second argument,
then go to the second digit of the first argument, then the second digit of the
second argument, and so on.  If one of the arguments runs out of digits, then any
remaining digits of the other argument should be used, in order.

For example, intermix(38, 72) should display 3782, and intermix(385, 724) should
display 378254.  And, intermix(3, 724) should display 3724, while intermix(385, 7)
should display 3785.  Finally, intermix(13579, 2468) should display 123456789.  You
may not use any FOR, WHILE, or DO-WHILE loops in your method; you must use recursion.
In addition, your method may not contain any String variables or String methods.
The method should not return anything.