Question: //Write a statement that calls the recursive method backwardsAlphabet() // with parameter startingLetter public class RecursiveCalls { public static void backwardsAlphabet(char currLetter) { if (currLetter
//Write a statement that calls the recursive method backwardsAlphabet()
// with parameter startingLetter
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;
}
}
1. Modify the file by writing a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter. Test and run. Submit.
2.
Use the recursive method sum (shown below) to illustrate this:
public int sum(int num)
{
int result;
if (num == 1)
result = 1;
else
result = num + sum(num-1);
return result;
}
3. Submit a working program that uses this recursive method and shows the result for n=1000 (40 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
