Question: 6 . Programming Task 3 For this task, you should implement a recursive function that gets 3 parameters and return a string that is made

6. Programming Task 3
For this task, you should implement a recursive function that gets 3
parameters and return a string that is made of the first two input parameters
repeatedly. This means the output contains the first input followed by the
second input, followed by the first input again, .....The number of repetition of
the input strings is specified by the third argument of the method.
Here are some examples:
interlace(Hello ,World ,0) returns
interlace(Hello ,World ,1) returns Hello
interlace(Hello ,World ,2) returns Hello World
interlace(Hello ,World ,3) returns Hello World Hello
The name of the method is interlace and the header of the method was
written for you in Lab2.java.
7. Programming Task 4
In this task, you are required to write a recursion that gets a string and two
characters and returns the substring that is enclosed in two given characters.
You can assume that the given string includes only one instance of each
enclosing characters.
For example, where the input string is This is [quite} an example! and the first
enclosing character is '[' and the second is '}', it should return quite.
The name of the method is getSubstring and the header of the method was
written for you in Lab2.java.
8. Programming Task 5
For this task, you need to write a recursion that converts a positive integer
including zero, to its binary equivalence. This method gets one integer input.
A binary form of an integer is calculated by repeatedly dividing the integer
number (and later, its quotient) by 2. You keep doing the division until the
quotient is zero. The reminders of the divisions, from the last division to the
first, form the binary representation of the integer number. Lets see an
example in which 23 is converted to a binary number. R stands for the
remainder.
23/2=11 R 1
11/2=5 R 1
5/2=2 R 1
2/2=1 R 0
1/2=0 R 1
Therefore, the binary representation of 23 is 10111.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!