Write a recursive method that takes as aparameter a non-negative integer and gen
ID: 3610975 • Letter: W
Question
Write a recursive method that takes as aparameter a non-negative integer and generates the followingpattern of stars. If the non-negative integer is 4, then thepattern generated is: **** *** ** * * ** *** **** Also, write a program that promts the user to enter the numberof lines in the pattern and uses the recursive method to generatethe pattern. For example, specifying the number of lines to be 4generates the preceeding pattern. Write a recursive method that takes as aparameter a non-negative integer and generates the followingpattern of stars. If the non-negative integer is 4, then thepattern generated is: **** *** ** * * ** *** **** Also, write a program that promts the user to enter the numberof lines in the pattern and uses the recursive method to generatethe pattern. For example, specifying the number of lines to be 4generates the preceeding pattern.Explanation / Answer
import java.io.*; import java.util.*; import java.lang.*; public class Recursive{ public static int num; public static int counter=0; public static void recurse(int number) { if(num==0) return; else { int temp; for(int i=0; i0) { System.out.println(); recurse(temp); } else { counter=1; System.out.println(); recurse(1); } } else { System.out.println(); temp=number+1; if(tempRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.