Question
1. Write a java program that calls a recursive method called repeat that accepts a string s and an integer n as parameters and that
1. Write a java program that calls a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated together n times. For example: repeat(cs, 3) returns cscscs, repeat (cs, 0) returns .
2. Write a recursive method isReverse that accepts two strings as a parameter and returns true if the two strings contain the same sequence of characters as each other but in the reverse order. For example, the string "hello" backwards is "olleh", so a call of isReverse("Java", "avaJ") would return true and isReverse( Java, ava) would return false.
3. Write a recursive method called starString that accepts an integer as a parameter and prints to the console a string of starts (asterisks) that is 2n (i.e. 2 to the nth power) long. For example: starString(0) should print * (because 2^0 == 1) starString(2) should print **** (because 2^2 == 4) starStrting(4) should print **************** (because 2^4 == 16)
Do so in Java!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started