Question: I need help with these Java programs. All the details are going to be provided below. Note: Program #1 and Program #2 should be implemented
I need help with these Java programs. All the details are going to be provided below.
Note: Program #1 and Program #2 should be implemented using recursion.
Program #1:

Testcase 1 -- zigzag(1)
Return: "*"
Testcase 2 -- zigzag(2)
Return: "**"
Testcase 3 -- zigzag(3)
Return: ""
Testcase 4 -- zigzag(4)
Return: ""
Testcase 5 -- zigzag(5)
Return: ">"
Testcase 6 -- zigzag(6)
Return: ">"
Testcase 7 -- zigzag(7)
Return: ">>"
Testcase 8 -- zigzag(8)
Return: ">>"
Testcase 9 -- zigzag(9)
Return: ">>>"
Testcase 10 -- zigzag(10)
Return: ">>>"
Program #2

Testcase 1 -- moveToEnd("hello", 'l')
Return: "heoLL"
Testcase 2 -- moveToEnd("hello", 'e')
Return: "hlloE"
Testcase 3 -- moveToEnd("hello there", 'e')
Return: "hllo thrEEE"
Testcase 4 -- moveToEnd("hello there", 'q')
Return: "hello there"
Testcase 5 -- moveToEnd("HELLO there", 'e')
Return: "HLLO thrEEE"
Testcase 6 -- moveToEnd("HHH", 'H')
Return: "HHH"
Testcase 7 -- moveToEnd("hahahaha", 'h')
Return: "aaaaHHHH"
Program #3
Given a stack as input, return a stack that has the same values, but in reverse order.
Program #4
Given a queue, return a new queue that has the same values in reverse order.
Initial Code:
import java.util.LinkedList; import java.util.Queue; import java.util.Stack; public class Drill02 { /* -------- Stacks/Queues -------- */ /* * Given a stack as input, return a stack that has the same * values, but in reverse order. */ static Stack reverseStack(Stack in) { return new Stack(); } /* * Given a queue, return a new queue that has the same values in * reverse order. */ static Queue reverseQueue(Queue in) { return new LinkedList(); } /* -------- Recursion -------- */ /* * Takes a number of characters to print as a parameter and returns * a String with one or two asterisks in the middle surrounded by * alligators. */ public static String zigzag(int n) { return ""; } /* * Takes a String and a character as parameters and returns * the string with all copies of the character moved to the end * and capitalized. */ public static String moveToEnd(String s, char c) { return ""; } } # Drill02 You must use recursion for zigzag and moveToEnd. *## zigzag n Write a recursive method zigzag that accepts an integer parameter 'n and that returns a string composed of 'characters as follows. The middle character of the output should always be an asterisk ("*"). If you are asked to return an even number of characters, then there will be two asterisks in the middle ("**"). Before the asterisk(s) you should have less-than characters (""). For example, the following calls produce the following output: Call | Return 'zigzag (1); zigzag (2); zigzag (3); 'zigzag (4); `> zigzag (5); zigzag (6); `> 'zigzag (7); zigzag (8); | -## moveToEnd Write a recursive method named "moveToEnd that accepts a string 's and a character c as parameters, and returns a new string similar to s. but with all instances of c moved to the end of the string. The relative order of the other characters should be unchanged from their order in the original string 's'. If the character is a letter of the alphabet, all occurrences of that letter in either upper or lowercase should be moved to the end and converted to uppercase. If is does not contain it should be returned unmodified. c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
