Write a recursive definition for the following method:
/**
Precondition: n >= 1.
Displays the symbol '#' n times on one line
and then advances to the next line.
*/
public static void displaySharps(int n)
For example, the call displaySharps(3) is equivalent to
System.out.println("###");
If you have trouble writing this method, simplify it so that the output does not advance to the next line. For that simpler case, you need not worry about the distinction between print and println. In the simpler case, you use only print. After doing the simpler case, try to do the exercise as stated.
A. Complete the definition of the following method. Your definition should be recursive.
/**
Precondition: n >= 0.
Returns 10 to the power n.
*/
public static int computeTenToThe(int n)
B. Complete the definition of the following method. Your definition should be recursive. Unlike the method in Question 1, this method does not restrict the sign or value of its argument. You can use the same technique you used for Question 2, but you should have one more recursive case for negative exponents. (Hints: 10n is 1/10n for negative values of n. Also, if n is negative, n is positive.)
/**
Precondition: n can be any int.
Returns 10 to the power n.
*/
public static int computeTenToThe(int n)