Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

RECURSIVE METHOD (Java) Fill in the missing piece of code where /*Your Solution

ID: 3672816 • Letter: R

Question

RECURSIVE METHOD (Java)

Fill in the missing piece of code where /*Your Solution goes here*/ is written.

Here is the same code again:

public class RecursiveCalls {
   public static void backwardsAlphabet(char currLetter) {
      if (currLetter == 'a') {
         System.out.println(currLetter);
      }
      else {
         System.out.print(currLetter + " ");
         backwardsAlphabet(--currLetter);
      }
      return;
   }

   public static void main (String [] args) {
      char startingLetter = '-';

      startingLetter = 'z';

      /* Your solution goes here */

      return;
   }
}

Challenge Activity 2.2.1: Calling a recursive method Write a statement that calls the recursive method backwardsAlphabet) with parameter startingLetter. 1 public class Recursivecalls 2 public static void backwardsAlphabet (char currLetter) £ if (currLettera) f System.out.println(currLetter); else f System.out.print(currLetter+""); backwardsAlphabet(--currLetter); 1e return; 12 13 public static void main (String [] args) f 14 15 16 17 18 19 28 char startingetter '-'; = startingetter = 'z'; Your solution goes here / return Run

Explanation / Answer

public class RecursiveCalls {
   public static void backwardsAlphabet(char currLetter) {
      if (currLetter == 'a') {
         System.out.println(currLetter);
      }
      else {
         System.out.print(currLetter + " ");
         backwardsAlphabet(--currLetter);
      }
      return;
   }

   public static void main (String [] args) {
      char startingLetter = '-';

      startingLetter = 'z';

    backwardsAlphabet(startingLetter);

      return;
   }
}